codeforces补题
文章平均质量分 78
对组赛疑惑的题目进行二次解释。
喜欢蓝喜欢白
这个作者很懒,什么都没留下…
展开
-
MEX and Increments
到底是谁来构成mex所需要的0~i-1的元素?让最接近i的数来构造!原创 2022-06-03 18:59:44 · 252 阅读 · 0 评论 -
Choosing Capital for Treeland(树形DP)
The country Treeland consists ofncities, some pairs of them are connected withunidirectionalroads. Overall there aren - 1roads in the country. We know that if we don't take the direction of the roads into consideration, we can get from any city to a...原创 2022-04-06 18:02:44 · 578 阅读 · 0 评论 -
Pipes
先从(1,1)开始找,对应数组就是a[0][0]若a[0][0] > 2:也就是此时只能向上或者向下流。就看a[1][0]能不能往右流。 若a[0][0] <= 2:他能往右流。这一列就过去了,就看下一列了,也就是a[0][1]。总结就是,当前若不能往下右流,就往上或下流后看另一行能不能往右,若还是不能往右,则不能流通。若最后留到了最后一列,但是只能流到上面一行,也就是r = 0.那也会失败,因为要求是到达(2,n+1)。完整代码:#include<bits/..原创 2022-04-06 13:09:36 · 204 阅读 · 0 评论 -
Baby Ehab Partitions Again
Baby Ehab was toying around with arrays. He has an arrayaaof lengthnn. He defines an array to be good if there's no way to partition it into22subsequences such that the sum of the elements in the first is equal to the sum of the elements in the secon...原创 2022-03-29 22:28:50 · 554 阅读 · 3 评论 -
Number of Ways
You've got arraya[1], a[2], ..., a[n], consisting ofnintegers. Count the number of ways to split all the elements of the array into three contiguous parts so that the sum of elements in each part is the same.More formally, you need to find the number...原创 2022-03-18 22:19:53 · 321 阅读 · 0 评论 -
Road Optimization
The Government of Mars is not only interested in optimizing space flights, but also wants to improve the road system of the planet.One of the most important highways of Mars connects Olymp City and Kstolop, the capital of Cydonia. In this problem, we on.原创 2022-03-16 15:25:25 · 180 阅读 · 0 评论 -
Factorials and Powers of Two
A number is calledpowerfulif it is a power of two or a factorial. In other words, the numbermmis powerful if there exists a non-negative integerddsuch thatm=2dm=2dorm=d!m=d!, whered!=1⋅2⋅…⋅dd!=1⋅2⋅…⋅d(in particular,0!=10!=1). For example11,4...原创 2022-03-16 08:38:52 · 285 阅读 · 2 评论 -
Epic Transformation
You are given an arrayaaof lengthnnconsisting of integers. You can apply the following operation, consisting of several steps, on the arrayaazeroor more times:you select twodifferentnumbers in the arrayaiaiandajaj; you removeii-th andjj-t...原创 2022-03-15 17:03:04 · 165 阅读 · 0 评论 -
Harmonious Graph
You're given an undirected graph withnnnodes andmmedges. Nodes are numbered from11tonn.The graph is consideredharmoniousif and only if the following property holds:For every triple of integers(l,m,r)(l,m,r)such that1≤l<m<r≤n1≤l<m&...原创 2022-03-15 13:21:28 · 1169 阅读 · 0 评论 -
New Year Permutation
User ainta has a permutationp1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutationa1, a2, ..., anisprettierthan permutationb1, b2, ..., bn, if and only if there exists an integerk(1 ≤ k ≤ n...原创 2022-03-15 00:21:10 · 78 阅读 · 0 评论 -
Say No to Palindromes
Let's call the stringbeautifulif it does not contain a substring of length at least22, which is a palindrome. Recall that a palindrome is a string that reads the same way from the first character to the last and from the last character to the first. Fo...原创 2022-03-14 23:29:58 · 374 阅读 · 0 评论 -
Swaps
You are given two arraysaaandbbof lengthnn. Arrayaacontains eachoddinteger from11to2n2nin an arbitrary order, and arraybbcontains eacheveninteger from11to2n2nin an arbitrary order.You can perform the following operation on those arr...原创 2022-02-14 21:06:49 · 554 阅读 · 0 评论 -
Ciel and Flowers
Fox Ciel has some flowers:rred flowers,ggreen flowers andbblue flowers. She wants to use these flowers to make several bouquets. There are 4 types of bouquets:To make a "red bouquet", it needs 3 red flowers. To make a "green bouquet", it needs 3 ...原创 2022-02-13 12:04:34 · 321 阅读 · 0 评论 -
Berland Crossword
Berland crossword is a puzzle that is solved on a square grid withnnrows andnncolumns. Initially all the cells are white.To solve the puzzle one has to color some cells on the border of the grid black in such a way that:exactlyUUcells in the top ...原创 2022-02-13 11:05:52 · 233 阅读 · 0 评论 -
Maze。
Pavel loves grid mazes. A grid maze is ann × mrectangle maze where each cell is either empty, or is a wall. You can go from one cell to another only if both cells are empty and have a common side.Pavel drew a grid maze with all empty cells forming a co..原创 2022-02-12 22:35:16 · 74 阅读 · 0 评论 -
Kefa and Park
题解就是树的遍历,只不过要注意一下,判断是否是叶子结点的方式:若深度为1,且u = h[u],即叶子结点。原创 2022-02-12 21:00:12 · 441 阅读 · 0 评论 -
Taxes
哥德巴赫猜想:1. 任何大于2的偶数都可以写成两个素数之和。因此所有偶数都能被拆除2个素数2. 任何大于7的奇数都可以写成三个素数之和。3 5 7 都是素数本身,大于7的素数可以有两种方式构建,一种:一个素数+2,二种:三个素数原创 2022-01-27 11:40:28 · 259 阅读 · 0 评论 -
Multiplication Table
Bizon the Champion isn't just charming, he also is very smart.While some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted ann × mmultiplication table, where the element on the inters..原创 2022-01-27 11:27:24 · 497 阅读 · 0 评论 -
Divine Array
Black is gifted with a Divine arrayaaconsisting ofnn(1≤n≤20001≤n≤2000) integers. Each position inaahas an initial value. After shouting a curse over the array, it becomes angry and starts an unstoppable transformation.The transformation consists of...原创 2022-01-26 11:48:55 · 182 阅读 · 0 评论 -
Strange Function
给一个n,我们要求f(1) + f(2) + ……+f(n)。其中f[x]等于不被x整除的大于1的最小整数。原创 2022-01-23 21:13:01 · 775 阅读 · 0 评论 -
Plus and Multiply
There is an infinite set generated as follows:11is in this set. Ifxxis in this set,x⋅ax⋅aandx+bx+bboth are in this set.For example, whena=3a=3andb=6b=6, the five smallest elements of the set are:11, 33(11is in this set, so1⋅a=31⋅a=3is ...原创 2022-01-23 13:25:05 · 793 阅读 · 0 评论 -
Balance the Bits
A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.You are given a binary原创 2022-01-21 12:14:20 · 608 阅读 · 0 评论 -
Monsters And Spells
Monocarp is playing a computer game once again. He is a wizard apprentice, who only knows a single spell. Luckily, this spell can damage the monsters.The level he's currently on containsnnmonsters. Theii-th of them appearskikiseconds after the start...原创 2022-01-20 20:06:29 · 397 阅读 · 0 评论 -
Palindromes Coloring
You have a stringssconsisting of lowercase Latin alphabet letters.You can color some letters in colors from11tokk. It is not necessary to paint all the letters. But for each color, there must be a letter painted in that color.Then you ca...原创 2022-01-15 13:22:46 · 358 阅读 · 0 评论 -
RGB Substring (hard version)
原题:You are given a stringssconsisting ofnncharacters, each character is 'R', 'G' or 'B'.You are also given an integerkk. Your task is to change the minimum number of characters in the initial stringssso that after the changes there will be a str...原创 2022-01-14 20:51:43 · 325 阅读 · 0 评论 -
Mind Control (思维)
oing your choices optimally. What is the greatest integerxxsuch that, no matter what are the choices of the friends you didn't choose to control, the element you will take from the array will begreater than or equal toxx?Please note that the friends ...原创 2022-01-14 19:07:05 · 691 阅读 · 0 评论 -
Minimize The Integer(贪心)
给出一串数字,通过无限次交换数字位置,使得最后的数字最小。且每次交换只能奇数与偶数交换。最后数字可以有前导0.原创 2022-01-12 16:34:30 · 247 阅读 · 0 评论 -
Phoenix and Distribution
将一个长度为n的字符串按任意顺序分成k份,最小化k份中的字典序最大字符串。原创 2022-01-12 13:06:06 · 160 阅读 · 0 评论 -
Chocolate Bunny (交互)
经过2*n次询问,找到一个为1到n的序列p。每次提问格式为:? x y。每次提问可以得到一个余数,如 ? 1 2,可以得到一个p[1] % p[2]的值。原创 2022-01-11 21:50:33 · 580 阅读 · 0 评论