Loading

Codeforces Contest 1804

感觉这场状态极差,几个结论题做的都贼慢。

A. Lame King

显然是先走正方形,然后不妨设接下啦往右走,那么一定可以走一步停一下再走,于是只用 \(2*y'-1\) 步。

B. Vaccination

先考虑怎样放最优,显然是是放到 \(t_1+w\) 的位置开始,然后贡献后面的 \(k\) 个在 \(t_1+w+d\) 的范围内的数,贪心的想越前越好。于是贡献完之后可以把这些全删了,变成了原问题并把答案加一。

C. Pull Your Luck

即求 \(\frac{p(p+1)}{2}\equiv -x\pmod n\),由于不一定有逆元,所以不能直接乘以 \(2\)。直接枚举 \([1,2n]\) 之内的 \(p\),把 \(2\) 除掉即可。容易证明这样取遍了整个剩余系。

D. Accommodation

每行显然是分开的,先分析一下这个答案是什么。考虑每有一个双人房占据两个 \(1\) 就有一个 \(1\) 没用了,于是答案就是 \(1\) 的个数减去双人房占据两个 \(1\) 的个数。

首先对于最小值,我们要让他尽量大,这很显然,对于每个 \(1\) 的连通块向下取整即可。否则要求尽量小,求出没有两个连续 \(1\) 的极长连续快,求它向下取整就是答案。

E. Routing

Consider such a solution. We use dynamic programming to find a Hamilton circle with length greater than \(1\).
And we can approach to every nodes only using one edge on from nodes on the circle.
lowbit(\(s\)) is determined to be the starting point, and \(dp[s]\) represents the possible end point set of the chain formed by the set \(s\).
In this way, we can find the Hamilton circle in \(n2^n\), but if we want to count it, we still need a \(n^22^n\) algorithm.

F. Approximate Diameter

G. Flow Control

H. Code Lock

posted @ 2023-03-13 09:48  Semsue  阅读(93)  评论(1)    收藏  举报
Title