[CF1227] Technocup 2020 - Elimination Round 3

Technocup 2020 - Elimination Round 3

Announcement Tutorial

Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3)

A - Math Problem

a.cpp 66008472

B - Box

b.cpp 66008579

C - Messy

括号构造题。(想复杂了)

剧透

实际上,设\(t\)\(s\)的任何排列,\(t\)可在\(n\)次操作内得到。

c.cpp 66009229

D2 - Optimal Subsequences (Hard Version)

一道排序+数据结构题。

d.cpp 66009561

E - Arson In Berland Forest

有趣的一道二分+搜索题。

注意常数!(\(nm\)的矩阵不要在旁边增加冗余字符(常数×3))

e.cpp 66775689

F2 - Wrong Answer on test 233 (Hard Version)

f2.cpp 66777574

有点技巧的计数题。

我的做法

注意到,我们实际只需要考虑所有不同的相邻\(h_i\)。(若\(h_i=h_{i+1}\),则答案\(i\)的贡献为\(0\)

不妨设\(h_i\ne h_{i+1}\)\(1<k\),则答案为:(用了对称矩阵的上三角求和法)

\[\begin{aligned} &\sum_{0\le j<i\le n,j+i\le n}{n\choose i,j,n-i-j}(k-2)^{n-i-j} \\ =&\frac 12\left(\sum_{0\le i\le n,0\le j\le n}{n\choose i,j,n-i-j}(k-2)^{n-i-j}-\sum_{0\le i=j\le n}{n\choose i,j,n-i-j}(k-2)^{n-i-j}\right)\\ =&\frac 12\left(\sum_{i=0}^n{n\choose i}\sum_{j=0}^n{n-i\choose j}(k-2)^{n-i-j}-\sum_{i=0}^n{n\choose i,i,n-2i}(k-2)^{n-2i}\right)\\ =&\frac 12\left(k^n-\sum_{i=0}^{n/2}{n\choose i}{n-i\choose i}(k-2)^{n-2i}\right) \end{aligned} \]

题解

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

这题卡空间!

posted @ 2021-05-20 20:31  frank3215  阅读(77)  评论(0)    收藏  举报