比赛链接
https://codeforces.com/contest/1551
1. A. Polycarp and Coins
1.1. 题意
给你一个数n,你要把他拆为$c_1+2c_2$的形式,你需要最小化$c_1$和$c_2$的差
1.2. 做法
对模3的余数进行分类讨论
1.3. 代码
1 |
|
2. B2. Wonderful Coloring - 2
2.1. 题意
给你一个长度为n的序列,你要用k种颜色给序列的每个元素染色,
- each element of the sequence is either painted in one of k colors or isn’t painted;
- each two elements which are painted in the same color are different (i. e. there’s no two equal values painted in the same color);
- let’s calculate for each of k colors the number of elements painted in the color — all calculated numbers must be equal;
- the total number of painted elements of the sequence is the maximum among all colorings of the sequence which meet the first three conditions.
你要最大化被染色的元素的个数
2.2. 做法
贪心染色,先把元素按照值分类,每个类中如果有超过k个颜色,则直接丢弃,最后把这些元素放到一起构成集合$S$,继续丢弃一些元素,直到$|s|$是k的倍数
2.3. 代码
1 |
|
3. C. Interesting Story
3.1. 题意
A story is called interesting if there exists a letter which occurs among all words of the story more times than all other letters together.
如果一个字符串中,有一个字符出现的次数,币其他字符出现的次数之和还要大,则这个字符串为有趣。
You are given a sequence of n words consisting of letters ‘a’, ‘b’, ‘c’, ‘d’ and ‘e’. Your task is to choose the maximum number of them to make an interesting story. If there’s no way to make a non-empty story, output 0.
给你一些字符串,你要从中选择最多的字符串,这些字符串拼在一起之后是一个有趣的字符串、
字符串只由abcde
五种字符构成
3.2. 做法
对每种字符分别判断,假设现在在处理a,每个字符串中a出现的次数为$a_i$其他字符出现的次数为$x_i$,然后对字符串按照$a_i-x_i$排序,贪心选择前几项即可
3.3. 代码
1 |
|
4. D2. Domino (hard version)
4.1. 题意
sb题目没营养,不展开了
4.2. 代码
1 |
|
- 本文作者: fightinggg
- 本文链接: http://fightinggg.github.io/yilia/yilia/QWQBDC.html
- 版权声明: 本博客所有文章除特别声明外,均采用 MIT 许可协议。转载请注明出处!