[CF1227] Technocup 2020 - Elimination Round 3
Technocup 2020 - Elimination Round 3
Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3)
A - Math Problem
B - Box
C - Messy
括号构造题。(想复杂了)
剧透
实际上,设\(t\)为\(s\)的任何排列,\(t\)可在\(n\)次操作内得到。
D2 - Optimal Subsequences (Hard Version)
一道排序+数据结构题。
E - Arson In Berland Forest
有趣的一道二分+搜索题。
注意常数!(\(nm\)的矩阵不要在旁边增加冗余字符(常数×3))
F2 - Wrong Answer on test 233 (Hard Version)
有点技巧的计数题。
我的做法
注意到,我们实际只需要考虑所有不同的相邻\(h_i\)。(若\(h_i=h_{i+1}\),则答案\(i\)的贡献为\(0\))
不妨设\(h_i\ne h_{i+1}\),\(1<k\),则答案为:(用了对称矩阵的上三角求和法)
题解
First of all, special judge for \(k = 1\), where the answer is zero.
Let \(d\) be the difference between the points for latest answer suit and the previous one. An valid answer suit means \(d > 0\).
For positions satisfying \(h_{i} = h_{i \space \mod \space n + 1}\), the answer for this position will not affect \(d\). Assume there's \(t\) positions which \(h_{i} \neq h_{i \space \mod \space n + 1}\).
For a fixed position \(i\) which \(h_{i} \neq h_{i \space \mod \space n + 1}\), let your answer for this position is \(a_{i}\) . If \(a_{i} = h_{i}\), then the \(d\) value will decrease by 1. We call this kind of position as a decreasing position. If \(a_{i} = h_{i \space \mod \space n + 1}\), then the \(d\) value increase by 1. We call this kind of position as a increasing position. Otherwise \(d\) value will not be affected, we call this kind of position zero position.
Obviously the number of increasing position should be exact larger then the decreasing position. So let's enumerate the number of zero positions. We can find the answer is equal to \(k^{n-t} \times \sum_{0 \leq i \leq t - 1}{[(k-2)^i \times \binom{t}{i} \times \sum_{[\frac{t-i}{2}]+1 \leq j \leq t - i}{\binom{t-i}{j}}]}\). \(i\) represent the number of zero positions and \(j\) represent the number of increasing positions.
The only problem is how to calculate \(\sum_{[\frac{t-i}{2}]+1 \leq j \leq t - i}{\binom{t-i}{j}}\) quickly. Due to \(\binom{n}{x} = \binom{n}{n-x}\), we can tell that when \(t - i\) is odd, \(\sum_{[\frac{t-i}{2}]+1 \leq j \leq t - i}{\binom{t-i}{j}} = 2^{t-i-1}\). Otherwise it is equal to \(\frac{2^{t-i} - \binom{t-i}{\frac{t-i}{2}}}{2}\).
Writer: RDDCCD
E - Not Same
构造题。
题解
将答案旋转90°来考虑(考虑\(n\)递增地构造)即可。
F - Xor-Set
这题卡空间!