![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
CodeForces
文章平均质量分 78
sakura7776
文化先和初中生同步
展开
-
CF1560E 每日一题 Polycarp and String Transformation
Polycarp has a string s. Polycarp performs the following actions until the string s is empty (t is initially an empty string):he adds to the right to the string t the string s, i.e. he does t=t+s, where t+s is a concatenation of the strings t and原创 2023-02-20 14:42:08 · 194 阅读 · 0 评论 -
CF1787C 每日一题 Remove the Bracket dp
RSJ has a sequence a of n integers a1,a2,…,an and an integer s. For each of a2,a3,…,an−1, he chose a pair of non-negative integers xi and yi such that xi+yi=ai and (xi−s)⋅(yi−s)≥0.Now he is interested in the valueF=a1⋅x2+y2⋅x3+y3⋅x4+…+yn−2⋅xn−1原创 2023-02-10 11:24:15 · 258 阅读 · 0 评论 -
CF1744F 每日一题 MEX vs MED 思维,双指针
outputstandard outputYou are given a permutation p1,p2,…,pn of length n of numbers 0,…,n−1. Count the number of subsegments 1≤l≤r≤n of this permutation such that mex(pl,pl+1,…,pr)>med(pl,pl+1,…,pr).mex of S is the smallest non-negative integer th原创 2023-02-02 14:05:57 · 339 阅读 · 0 评论 -
CF1743D 每日一题 Problem with Random Tests
You are given a string s consisting of n characters. Each character of s is either 0 or 1.A substring of s is a contiguous subsequence of its characters.You have to choose two substrings of s (possibly intersecting, possibly the same, possibly non原创 2023-02-01 14:08:05 · 148 阅读 · 0 评论 -
CF1750D 每日一题 Count GCD
You are given two integers n and m and an array a of n integers. For each 1≤i≤n it holds that 1≤ai≤m.Your task is to count the number of different arrays b of length n such that:1≤bi≤m for each 1≤i≤n, andgcd(b1,b2,b3,...,bi)=ai for each 1≤i原创 2023-01-31 13:20:36 · 91 阅读 · 0 评论 -
CF1741E 每日一题 Sending a Sequence Over the Network
The sequence a is sent over the network as follows:sequence a is split into segments (each element of the sequence belongs to exactly one segment, each segment is a group of consecutive elements of sequence);for each segment, its length is written nex原创 2023-01-29 15:27:35 · 136 阅读 · 0 评论 -
CF1774D 每日一题 Same Count One
ChthollyNotaSeniorious received a special gift from AquaMoon: n binary arrays of length m. AquaMoon tells him that in one operation, he can choose any two arrays and any position pos from 1 to m, and swap the elements at positions pos in these arrays原创 2023-01-27 13:24:42 · 90 阅读 · 1 评论 -
CF1779D 每日一题 Boris and His Amazing Haircut
Boris thinks that chess is a tedious game. So he left his tournament early and went to a barber shop as his hair was a bit messy.His current hair can be described by an array a1,a2,…,an, where ai is the height of the hair standing at position i. His d原创 2023-01-26 12:08:11 · 221 阅读 · 0 评论 -
CF1765D 每日一题 Watch the Videos
Monocarp wants to watch n videos. Each video is only one minute long, but its size may be arbitrary. The i-th video has the size ai megabytes. All videos are published on the Internet. A video should be downloaded before it can be watched. Monocarp has原创 2023-01-25 16:54:22 · 203 阅读 · 0 评论 -
Educational Codeforces Round 141 (Rated for Div. 2) 题解
Educational Codeforces Round 141 (Rated for Div. 2) 题解原创 2023-01-09 13:39:23 · 291 阅读 · 0 评论 -
Codeforces Round #842 (Div. 2) 题解
最后,我们考虑环内时候有两个位置相邻,如果存在至少一种相邻的情况,我们可以在该环操作的最后,不去操作这两个相邻的位置,最后得到一个相反的相邻对,满足题目要求,该环的操作次数为 k - 2 次。给一个长度为 n 的数组 a,试构造排列 p 和 q ,使得对于任意 1原创 2023-01-06 11:41:21 · 348 阅读 · 0 评论 -
Codeforces Round #838 (Div. 2) 题解
对于一个长度为 k 的01串,定义其 extension:长度为 2k - 1 的01串,第 2i - 1 位是原串的第 i 位,构造方式有2^(k-1)种(可以理解为长度k的串,两两字符之间共 k - 1 个空,每个空可以插入0或1)。直接对数组 a 从小到大排序,以最小元素的两倍为基准,将其后不大于基准值的元素全部构造为基准值,若当前元素已经大于该元素的两倍,将基准值不断乘2,直至基准值大于当前元素,然后构造,依次类推,注意计数并离线处理答案。3. a < b,意义同上,令 x = i ,继续遍历。原创 2022-12-16 12:51:53 · 722 阅读 · 0 评论 -
Educational Codeforces Round 139 (Rated for Div. 2) 题解
定义 (x , y) , (x + 1, y + 1) , (x + 2, y + 2) , (x + 3, y + 3) , ...... , (x + k, y + k) 为长度 k + 1 的数对链,当该链上所有数对都为 lucky 时,称该数对链为 lucky。给定一个数 n ,对于 n 组 x ,y,问以数对 (x , y) 为开头的 lucky 数对链的长度最大是多少。既然只有一位非0,那么一定是首位非0,直接计算,计算方式就是 n 的位数减1 * 9,加上 n 的最高位即可。原创 2022-12-15 08:49:13 · 427 阅读 · 3 评论 -
Codeforces Round #836 (Div. 2) A~D 题解
n为奇数的情况下,构造 n - ( n + 1 ) / 2 + 2 ~ n , n + 3 ~ n + ( n + 1 ) / 2 + 2 , 总和是 ( n + 1 ) ^ 2。的情况下,首先可以得到1和3的异或值是2,所以构造 n / 2 对1和3,两两异或得到 n / 2 个2,且 n / 2为奇数,所以异或值等于2,均值也等于2。n 为偶数的情况下,比较好构造,直接以 n 为中心 ,构造 n / 2 个依次小 1的数,构造 n / 2个依次大1的数,总和是 n ^ 2。原创 2022-11-26 23:18:38 · 207 阅读 · 0 评论 -
Codeforces Round #783 (Div. 2) 题解
首先,对于 n , m较短的那边,我们可以到达而不花费多余代价。此时长的那边剩余的部分,我们需要多花费(abs(n - m)- 1)的代价,对于 abs(n - m) % 2 == 0 的情况,还需要多花费一个代价。给 n * m 大小的地图 ,从(1,1)出发,终点为(n,m),每次可以选择上下左右其中一个方向移动一格,但不能连续两次向同一个方向走,问最少几步能达到终点,不能到达则输出-1。我们枚举每一个位置是0的情况,将两边每一个元素构造为刚好满足情况的数,这样得到局部最优,再将全部情况取最小即可。原创 2022-11-24 08:36:38 · 99 阅读 · 0 评论 -
Codeforces Round #835 (Div. 4) 题解 A-G
每做完一种工作, k 天内不能再做,给定 c 和 d ,意为在 d 天内获得 c 元,问能够接受最大的 k 约束是多少,输出 k 的值。对于一个限制 k ,我们的工作模式是 k + 1天的循环,取模每次做价值最大的工作即可(也有可能不工作),然后check判断当前 k 能不能达成目标。如果记录到相邻两数存在上升现象时,每次记录较大值,此后如果记录到有数小于记录值,输出NO,遍历结束后若合法,输出YES。给一个长度为 n 的数组 a ,对于每一个数,输出其与最大值的差,对于最大值本身,输出其与第二大值的差。原创 2022-11-23 20:26:16 · 263 阅读 · 0 评论 -
Codeforces Round #779 (Div. 2) 题解
给定 l , r,取值在 [ l , r ] ,长度为 r - l + 1 的某个排列 a ,该排列 a 所有元素与某个 x 异或形成了新的排列,现在给出这个新的排列,求解 x ,可能有多种答案,输出任意一种。现在给出 c 数组,ci 代表 排列 p 的 i circle 排列 的power,问是否存在合法的排列 p ,满足给定的 c。给一串长度为 n 的01串,先要向其中插入若干个1,保证该串的所有子序列的0的数量不超过1,问最少插入几个1可以满足要求。原创 2022-11-23 13:50:25 · 326 阅读 · 0 评论 -
Codeforces Round #788 (Div. 2) A-D 题解
所以,我们依次向平面内添加这三种直线,得到的结果一定是最优的。给两个由1~n组成的排列a,b,再给出数组c,c中的 c[i] == 0代表该位置可以从 a[i],b[i]中任选一个填入,若不等于0,则代表该位置已经固定为这个数。给一个长度为n的字符串和k个特殊字母,给定一种操作,每一轮操作,从字符串从左网友看,可以将特殊字母的左边字母删掉,问这种操作最多能做几轮。给定有n个元素的数组a(有正有负),给定一种操作,可以选择一正一负两个元素,交换符号,问能否通过这种操作,令数组按升序排列。递推公式+二分答案。原创 2022-11-17 10:44:27 · 195 阅读 · 0 评论 -
Codeforces Round #806 (Div. 4) 题解
先处理一遍输入,保留 所有 ai < i , 开两个数组分别记录一下 满足要去的 id 和 val ,对 val 数组进行sort,然后 对 id 数组的每个元素在 val 数组中 upper_bound 一下,记录位置为k,则当前第 i 个元素,对其满足 ai < i < aj < j 的 aj 有 cnt - k + 1个,每次记录答案。有一个位数为n的密码锁,每位是0-9,现给出密码锁的最终组合,并给出对每位密码的操作过程(U代表该位数加1,D代表该位数减1,均0-9循环)求最初的密码锁组合是多少。原创 2022-11-01 10:44:40 · 270 阅读 · 0 评论 -
Codeforces Round #802 (div.2) 题解
有n个水池,第i个水池的容积为 vi 单位,每个池子上方有一根管子,若打开,则可以每秒流出1个单位的水。并且只开最左边的管子,不会存在浪费的情况(比如中间有个池子特别大,后面池子都很小,若开该池子后面的水管,会导致有的水填完最后一个池子就流掉了,没有贡献)所以我们只需要算出开几根管子,全放到左边就能保证最优。贪心,对于当前值向右,权值 (i − 1) * m + j 的 j ++,对于当前值向下,权值 (i − 1) * m + j 的 i ++,显然优先向右走最合算,一直走到最右后开始向下走。原创 2022-10-31 19:12:55 · 163 阅读 · 0 评论 -
Codeforces Round #830 (Div.2) 题解
查询时,如果map2中没有记录,就直接从k开始遍历,操作同D1.如果有记录,那么看map3,先找到第一个map3中不小于k的值,然后开始遍历,从删的数里面直接找满足条件的数,找到就输出,如果比map2[t]大了,就不如直接从map2[t]开始找。只操作an,只操作an-1,和二者都操作的代价分别为1,2,3,暴力看一下哪个满足条件,输出最小的。:给一个集合,最初只有一个0,每次给出两种操作:1.向集合中加入一个x(保证可以加入)2. 给一个k,问最小的能整除k的,且不在集合内的数是多少。原创 2022-10-23 22:57:52 · 1328 阅读 · 3 评论 -
CodeForces Round #818 (div.2) A-C 题解
A - Madoka and Strange Thoughts B - Madoka and Underground Competitions C - Madoka and Formal Statement原创 2022-10-04 13:06:55 · 190 阅读 · 0 评论 -
CodeForces Round #821 div.2 A-D题解
CodeForces Round #821 div.2 A-D题解 A.Consecutive Sum B.Rule of League C.Parity Shuffle Sorting D1. Zero-One (Easy Version)原创 2022-09-23 15:32:49 · 249 阅读 · 0 评论 -
CodeForces Round #715(div. 2) A-D 题解
CodeForces Round 715(div 2) A-D 题解 A.Average Height B. TMT Document C.The Sports Festival D. Binary Literature原创 2022-09-21 12:07:18 · 269 阅读 · 0 评论