div 1870 div1 div2
Codeforces Round 905 (Div. 2)
目录写在前面ABCD1/D2E写在最后 写在前面 比赛地址:https://codeforces.com/contest/1884 oonp 这场 div2 怎么才 2k5 人打啊我草 里面还不知道多少大神的小号,呃呃 打了 1k3 掉了 75 分也是牛逼 A 考虑如何拼出一个长度为 \(n-k\) ......
Codeforces Round 905 - div.3(A B C D E)
目录Codeforces Round 905 (Div. 3)A. MorningB. Chemistry Codeforces Round 905 (Div. 3) A. Morning 模拟光标移动即可 void solve(){ string ss; cin >> ss; char ch = ......
Codeforces Round 904 (Div. 2)
目录写在前面ABCD写在最后 写在前面 比赛地址:https://codeforces.com/contest/1884 捏吗我不会容斥,我是飞舞。 A \(k\le 10\),于是直接枚举 \(x\sim x+20\) 检查即可。 // /* By:Luckyblock */ #include < ......
Codeforces Round 905 Div 1 (CF1887)
A1. Dances (Easy version) 把 \(a,b\) 序列都从小到大排序,\(a\) 贪心删大的,\(b\) 贪心删小的,二分答案并 \(O(n)\) \(\text{check}\)。 Code ```cpp const int N=1e5+5; int T,n,m; int a ......
Codeforces Round 887 (Div. 2)
Codeforces Round 887 (Div. 2) A. Desorting 解题思路: 每次操作能使相邻数之差减\(2\),设最小相邻数之差为\(mind\),答案为\(ans = (mind + 1) / 2\)。 代码: #include <bits/stdc++.h> using n ......
Codeforces Round 855 (Div. 3) C. Powering the Hero
有 \(n\) 张卡的卡堆,你可以自顶向下抽卡。装备卡显示数值为 \(a_i(a_i>0)\) ,英雄卡显示数值为 \(a_i = 0\) 。 如果是装备卡,你可以将卡抽出放在装备堆。如果是英雄卡,你可以将装备堆顶端的一张数值为 \(x\) 的装备卡装备给英雄,英雄数值 \(+ x\) 。无论是否装 ......
Codeforces Round 857 (Div. 2) B. Settlement of Guinea Pigs
你非常喜欢豚鼠。每个笼子可以住两只豚鼠,且你不想把每个笼子放入不同性别的豚鼠。豚鼠只有两种性别。假设你买到豚鼠时并不知道性别,只有医生能够分辨。 接下来的 \(n\) 天方案中,若第 \(i\) 天为 \(1\) ,你买入一只豚鼠;若为 \(2\) ,你请医生分辨你的豚鼠性别。 给出方案,你最少需要 ......
Nebius Welcome Round (Div. 1 + Div. 2) B. Vaccination
你管理一个疫苗接种站,将会有 \(n\) 个人前来接种疫苗。第 \(i\) 个到来的人时间为 \(t_i\) ,已知每个人的等待时间不会超过 \(w\) 分钟。 疫苗存放在特质冰箱中,一袋疫苗有 \(k\) 支,当一袋疫苗在 \(x\) 时刻打开时,它的有效时间为 \(d\) 。 现在询问最少需要打 ......
Educational Codeforces Round 145 (Rated for Div. 2) B. Points on Plane
给一个二维平面,你需要在上面放 \(n\) 个芯片。将一个芯片放在 \((x, y)\) 的代价为 \(|x| + |y|\) 。放 \(n\) 个代价的代价为,所有芯片中耗费的最大代价。并且你需要保证任意两个芯片之间的距离严格 \(> 1\) 。 现在给出 \(n\) 给芯片,询问放 \(n\) ......
Codeforces Round 875 (Div. 2) C. Copil Copac Draws Trees( DFS )
Codeforces Round 875 (Div. 2) C. Copil Copac Draws Trees 思路: 在输入树的边的同时记录他们的输入顺序 从 1 开始跑 DFS ,遇到未连上的边时 , 有两种情况(用 q 表示当前点的顺序序号) 1.边的顺序在这个点连上之前,那么 DFS 的 ......
Educational Codeforces Round 149 (Rated for Div. 2)
这场D被切穿了。 A题 答案为 x 或者 x-1 1 B题 答案就是最长的连续一段的长度+1 证明的话大概可以将它看成是几段连续上升和下降的段,然后在峰谷、峰顶分别填上最小、最大,剩下的就依次递增或递减就行。 C题 将一段连续的0/1视作一个块,那么我们最小化这个块的数量就行。 D题如果猜到如果有解 ......
Codeforces Round 863 (Div. 3) B. Conveyor Belts
给一个 \(n \times n\) 的矩阵, \(n\) 是偶数。将矩阵按圈分割,同一圈的位置可以不消耗代价移动,可以消耗一个代价移动到相邻圈。 给出 \(n, x_1, y_1, x_2, y_2\) ,询问 \((x_1, y_1)\) 移动到 \((x_2, y_2)\) 的代价最小是多少。 ......
Codeforces Round 865 (Div. 2) B. Grid Reconstruction
给一个 \(2 \times n\) 的网格,且 \(n\) 是偶数。你需要将 \(1 \sim 2 \times n\) 填入这个网格。 一条路径是从 \((1, 1)\) 开始,每次只能向右或向下,到 \((2, n)\) 结束时,所经过的位置。按经过点的顺序标号,一两条路径的代价是 \(cos ......
Codeforces Round 902 (Div. 2, based on COMPFEST 15 - Final Round)
\(D. Effects of Anti Pimples\) 对每个数字能到达的所有位置先预处理最大值,那么就代表选择这个数字之后真实的贡献,那么对这样的预处理值,最小值显然只有一种做法,为 \(2^0\) ,第二小的值应该可以与最小值一起选择,所以答案为 \(2^1\) ,以此类推之后,每个值乘上 ......
Codeforces Round 872 (Div. 2) B. LuoTianyi and the Table
给一个 \(n \times m\) 的矩阵和 \(n \times m\) 个数,你需要把这些数填入矩阵。保证 \[\sum_{i=1}^n \sum_{j=1}^m \left ( \mathop{max}\limits_{1 \leq x \leq i, 1 \leq y \leq j} a_ ......
Codeforces Round 871 (Div. 4) D. Gold Rush
给一个堆 \(n\) 个石子,如果可以分裂为整数,它将分裂为 \(\frac{1}{3} n\) 和 \(\frac{2}{3} n\) 的两堆石子。并且新石堆会继续分裂。 询问过程中是否出现过大小为 \(m\) 的石堆。 显然记忆化 \(dfs\) 即可。 记忆数组一般开全局。容易观察到值域很大, ......
Codeforces Round 875 (Div. 2) B. Array merging
给定两个长为 \(n\) 的数组 \(a\) 和 \(b\) 。你需要将 \(a\) \(b\) 归并成一个数组 \(c\) 。询问所有归并方法中,连续数相同的子段最长为多少。\(1 \leq a_i, b_i \leq 2n\) 。 显然归并在 \(a\) 可以任选一段 \([l_1, r_1]\ ......
Codeforces Round 879 (Div. 2) B. Maximum Strength
定义正整数 \(C = \overline{c_1c_2 \cdots c_k} = c_1 \cdot 10^{k-1} + c_2 \cdot 10^{k - 2} + \cdots + c_1\) 。 假设有两个正整数 \(X = \overline{x_1x_2 \cdots x_n}, Y ......
Educational Codeforces Round 149 (Rated for Div. 2) C. Best Binary String
给一个字符串 \(s\) 包含 \(0, 1, ?\) 。 定义一个 \(01\) 串 \(s\) 的 \(cost\) 为:选择 \(s\) 的任意一个子段 \([l, r]\) 并 \(reverse\) 。将 \(s\) 变为一个非降序序列时的 \(reverse\) 最小次数即 \(cost ......
Codeforces Round 901 (Div. 2)
Codeforces Round 901 (Div. 2) 比赛链接 "考古"啦!之前没有做,现在补上 A. Jellyfish and Undertale 题目链接 思路: 按理说用模拟应该也是可以做到的,但是我应该没有写好,因为我们要找的是最大时间,所以我们每次加上的是min(a-1,x[i]) ......
Educational Codeforces Round 150 (Rated for Div. 2)
A题直接拆成 1 1 n-2 <=4时bob,否则alice B题直接模拟一下就行 C题开始想复杂了,我们直接枚举是哪个字符转成哪个字符即可,如果是变大,一定是放在最左,如果是变小,一定是放在最右,爆算即可。 D题,显然N^2dp,但是还是想错一些细节,假设按右端点排序后,当前考虑第i个区间,假设我 ......
Codeforces Round 878 (Div. 3) C. Ski Resort
你有连续的 \(n\) 天假期,第 \(i\) 天的温度为 \(a_i\) 。你计划在这 \(n\) 天中选择连续的若干天去旅游,至少为 \(k\) 天。给定一个 \(q\) ,你需要确保你出去旅游的时间中每天的温度都 \(\leq q\) 。询问你有多少种计划旅游的方案。 不难用双指针找出所有连续 ......
Educational Codeforces Round 150 (Rated for Div. 2) B. Keep it Beautiful
数组 \(a = [a_1, a_2, \cdots, a_n]\) 被称为是美丽的,如果可以将 \([1, x]\) 段移到 \([x + 1, n]\) 段后面,\(x \geq 0\) ,数组可以构成非降序。 现在有一个数组 \(a\) (一开始为空)和 \(q\) 个询问,第 \(i\) 个 ......
Codeforces Round 884 (Div. 1 + Div. 2) B. Permutations & Primes
给一个正整数 \(n\) ,你需要构造一个 \(n\) 的排列 \(p_1, p_2, \cdots, p_n\) 。对于排列 \(p\) 的每个子段 \([l, r]\) ,\(mex_{i = l}^{r} a_i\) 的结果为质数的次数尽可能多。 此处的 \(mex\) 最小排除值最低为 \( ......
Codeforces Round 882 (Div. 2) B. Hamon Odyssey
给一个长为 \(n\) 的数组 \(a_1, a_2, \cdots, a_n\) 。定义 \(f(l, r) = \&_{i=l}^{r} a_i\) 。 你需要对 \(a\) 进行分段,使得各段的 \(f(l, r)\) 之和最小。在各段 \(f(l, r)\) 之和最小的情况下,尽可能分出更多 ......
div通过append添加的元素无法通过jquery元素选择器选择
$("#" + msgid).append(data + '<br><br><br><div class="box-copy" id=' + copyid + '>复制内容</div>') 此时无法通使用 $(".box-copy").click()需要使用: $(document).on('cli ......
Educational Codeforces Round 152 (Rated for Div. 2) B. Monsters
有 \(n\) 个怪物,第 \(i\) 个怪物的血量为 \(a_i\) 。英雄一次攻击可以造成 \(k\) 点伤害,但只会攻击当前生命值最高的怪物。若有多个最高血量的怪物,则选择编号最小的怪物攻击。当怪物的血量 \(\leq 0\) 时则被消灭。 输出一个排列,表示怪物被消灭的编号顺序。 容易想到, ......
Codeforces Round 888 (Div. 3) C. Tiles Comeback
有 \(n\) 个瓷砖和一个正整数 \(k\) ,第 \(i\) 个瓷砖染色为 \(c_i\) 。你一开始在第 \(1\) 块瓷砖上,可以向右跳到任意一个位置的瓷砖。你可以得到一个长为 \(p\) 的路径,长度代表你曾经站过的瓷砖。 你需要确定是否存在一条长度为 \(p\) 的路径满足以下条件: 路 ......
Codeforces Round 888 (Div. 3) C. Tiles Comeback
有 \(n\) 块瓷砖和一个正整数 \(k\) ,第 \(i\) 块瓷砖染色为 \(c_i\) 。一开始站在第 \(1\) 块瓷砖往,然后可以开始往右跳吗,到第 \(n\) 块瓷砖停止。你可以得到的路径长度 \(p\) 为你从 \(1\) 到 \(n\) 踩过瓷砖的数量。 你需要确定是否存在一条长度 ......
Codeforces Round 893 (Div. 2) C. Yet Another Permutation Problem
有一个 \(gcd\) 游戏,按以下步骤进行: 选择一个 \(n\) 的排列 \(p_1, p_2, \cdots, p_n\) 。 对于每个 \(i\) ,\(d_i = gcd(p_i, p_{i \% n + 1})\) 排列 \(p\) 的 \(score\) 为数组 \([d_1, d_2 ......