We will hold AtCoder Beginner Contest 241(Sponsored by Panasonic).
- Contest URL: https://atcoder.jp/contests/abc241-
- Start Time: http://www.timeanddate.com/worldclock/fixedtime.html?iso=20220226T2100&p1=248
- Duration: 100 minutes
- Number of Tasks: 8
- Writer: math957963,Nyaan,sugarrr
- Tester: kyopro_friends,Nyaan
- Rated range: ~ 1999
- The point values will be 100-200-300-400-500-500-600-600.
We are looking forward to your participation!
The link is broken. Correct link
i feel today's D and E were easy.
and hardest a
I'm getting the wrong answer in 2 test cases in E. can anyone help me, why is it so? Thanks submission
I reordered some lines of your code. Now it can pass: Submission
Basically, your original code is checking for == 3 too late. You incremented vis[md], but not check for == 3 immediately. Instead, you waited until a long time after you check for == 3.
Please see my submission above.
Thanks for your help
In fact, another way to fix the original submission is to change the 2*n for loop to 3*n.
Then, it can pass all tests. Submission
Could someone explain, why into the Editorial for problem E the following property applies.
$$$\mathbf{f}(i) = (i + A_i) mod N$$$
Editorial Reference : https://atcoder.jp/contests/abc241/editorial/3480
The function $$$f$$$ represents applying the operation one time. Note that the only thing that matters is the remainder of candies modulo $$$N$$$, since we never actually need the total value. Also, modulo operation distributes across sums. So if we currently have $$$i$$$ candies modulo $$$N$$$, then the amount of candies we will have after applying the operation is $$$f(i) = (i + A_i) \mod N$$$.
Gotcha, thanks for the clear explanation.
For problem E, I find the period as follows.
At first, we add A0, and then we add Ax, where x=A0%N. To make this more clear and simple, we could just set x=3(note that it could be any index), i.e., A0,A3. Similarly, we could just write down the added elements in a sequence like, A0,A3,A7,A4,...
Note there are at most N elements, and thus sooner or later, the same element will be added again. For instance, A0,A3,A7,A4,...A9,A7, where A7 is the first element which appears again. This means, (A0+A3+A7+A4+..+A9)%N=7, and (A0+A3)%N=7, which further implies that (A7+A4+...+A9)%N=0. Therefore, (A0+A3+A7+A4+...+A9+A7)%N=(A0+A3+0+A7)%N=(A0+A3+A7)%N=4. Then, the next added element after A7 is A4. Now, we could see that the sequence becomes A0,A3,A7,A4,...A9,A7,A4, and by similar induction, we could see that the period has been found, which is (A7,A4,..A9). Finally in a word, the sequence is A0,A3,(A7,A4,..A9),(A7,A4,...,A9),...