We will hold AtCoder Grand Contest 062. This contest counts for GP30 scores.
- Contest URL: https://atcoder.jp/contests/agc062
- Start Time: http://www.timeanddate.com/worldclock/fixedtime.html?iso=20230521T2100&p1=248
- Duration: 180 minutes
- Number of Tasks: 6
- Writer: chinerist
- Tester: maspy, HIR180
- Rated range: 1200 -
The point values will be 400-700-800-1100-1300-2000.
We are looking forward to your participation!
Recently we are experiencing DDoS attacks and our website can be unstable during the contest. To mitigate the risk that the contest gets unrated, we will upload the PDF statement when the rated registration is closed (i.e. 5 minutes after the contest starts). We will later post the link here.
Problem Statement (link).
Hope to not brick A this time
Might as well start with B.
Well, this time it's B for which I have completely no idea how to even approach it :)
Maybe even with C next time
How to solve B
Let's say a subsequence is compact if all the adjacent numbers differ by 1.
After one operation, the permutation is partitionable into at most 2 compact subsequences.
After k operations, 2^k of them, and it turns out this is the IFF condition.
Let's look at the operations in reverse order.
We first sort all the compact subsequences: let's say there are M of them, S_1, ..., S_M.
One reverse operation allows you to pick a subset of them and place them at the end. When you select such subset, they have to form a suffix of S_1, ..., S_M by definition. It now splits into two independent part, [S_1, ..., S_i] [S_i+1, ..., S_M], and both part acts independently till the end.
Now set DP[x][l][r]: min cost to solve the interval [S_l, ..., S_r] using x last operations, 1 <= l <= r <= M. Transition is just iterating over all suffix.
Thanks!
Another way to look at it: for each operation, assign 0 or 1 to each number and look at the operations in reverse order. Then the initial order of any two elements is determined by which has 0 in the first operation where they have different numbers; if there's no such operation, then it's the order in $$$P$$$.
Since no editorial yet, why this stupid solution for C is fast enough?
Sort $$$a_i$$$ by increasing, and maintain the set $$$S_i$$$ of numbers representable with $$$a_1, \ldots, a_i$$$ as a union of segments. If there at least $$$k$$$ non-representable numbers less than $$$a_{i + 1}$$$, print them, otherwise find $$$S_{i + 1} = S_i \cup (S_i + a_{i + 1})$$$.
This is indeed equivalent to the intended solution. When you add $$$a_i$$$ and there are less than $$$k$$$ non-representable values, it means there are no more than $$$k$$$ segments before $$$a_i$$$. Therefore the number of segments increases by at most $$$k$$$ after adding $$$a_i$$$.
But why can't segments after $$$a_i$$$ grow exponentially? I must be missing something.
Heavy plus. I just wrote that out of desperation. The solution is super obvious, but why it works...
Same, but 2 minutes too late...
The segments after $$$a_i$$$ are a union of $$$(S_i+a_i)$$$ and something. Therefore the number of segments is at most the number of segments in $$$(S_i+a_i)$$$, which is just the number of segments in $$$S_i$$$.
Can't say I get it still. The trivial upper bound for size of "union of $$$(S_i + a_i)$$$ and something" is $$$|S_i + a_i|$$$ + |something|, unless there's something more to be said about their superposition. Why can't the two be just disjoint, for instance?
Let $$$V_i=a_1+a_2+\cdots+a_i$$$. We can prove that, after adding $$$a_i$$$, there are at most $$$K \times i$$$ non-representable numbers in the range $$$[0,V_i]$$$. (Note that I'm now talking about the number of values, not the number of segments.)
Let's say $$$S_{i-1}$$$ satisfies the condition and let's see what happens after adding $$$a_i$$$. In the range $$$[0,a_i]$$$, there are at most $$$K$$$ non-representable numbers. In the range $$$[a_i,V_{i+1}]$$$, there are at most $$$K \times i$$$ non-representable numbers. This is because this range contains all elements of $$$(S_i+a_i)$$$.
The intended solution keeps non-representable numbers in $$$[0,V_i]$$$. Keeping segments is almost the same as that.
Ah, now in terms of non-representable numbers below $$$V_i$$$ this is much more clear. Thanks for your explanation!
How to solve D?
In general, after any number of steps there exist numbers $$$L, R$$$ such that we can be anywhere in the region $$$L \leq |x| + |y| \leq R$$$. If the next step is $$$d$$$, then the new boundaries are $$$R' = R + d$$$, $$$L' = \max(0, L - d, d - R)$$$. If we additionally put an upper bound $$$M$$$, then the first one simply becomes $$$R' = \min(M, R + d)$$$. Note that if $$$D$$$ is the largest step in the set, we have $$$M \geq D / 2$$$ to be able to make the step $$$D$$$. Also, if answer $$$M$$$ exists, it is at most $$$D$$$.
Respective to the upper bound $$$M$$$, say that a step $$$d$$$ is large if $$$d > M$$$, and small otherwise. Note that once $$$R = M$$$, is always stays that way (provided on every step $$$L \leq R$$$), thus any solution step sequence can be divided into two phases: before and after $$$R$$$ reaches $$$M$$$. With an exchange argument one can prove that the second phase should use steps by decreasing of magnitude. Further, in the second phase:
Let $$$S$$$ be the sum of all small steps. Now there are a few cases:
Note that we can only consider $$$D, D_1, D_2$$$ above among the smallest two large steps available (check all combinations). Checking conditions requires finding the smallest representable sum $$$s \geq x$$$ of small steps. These can be maintained and queried with a bitset of reachable sums, along with gradually increasing $$$M$$$.
Thanks!
So:
1) Does unrated participation count towards race score?
2) Does unrated participation count towards the number of won rounds? Currently neither of us has it counted as a win.
1) They count. (See the discussion here).
2) They also count. It must be a small bug and we will fix it.
Even though I was angry at some of the problems in this round, I want to thank you, maroonrk, for slightly lowering your difficulty standards and allowing AGC where it is actually possible to solve more than 1 problem.
On kenkoooo, problem F is shown as $$$0$$$ points instead of $$$2000$$$. Someone please fix it.
So lucky to take the first place in this round! But because there was a conflict with the APIO closing ceremony in the first thirty minutes, I chose unrated to participate TAT.
C and D seems very magical, I solved them just by feeling and guessing.
I also want to ask the same question as Radewoosh's.
So when editorial?