Блог пользователя chokudai

Автор chokudai, история, 2 года назад, По-английски

We will hold AtCoder Beginner Contest 241(Sponsored by Panasonic).

We are looking forward to your participation!

  • Проголосовать: нравится
  • +47
  • Проголосовать: не нравится

»
2 года назад, # |
Rev. 2   Проголосовать: нравится +25 Проголосовать: не нравится

The link is broken. Correct link

»
2 года назад, # |
  Проголосовать: нравится +9 Проголосовать: не нравится

i feel today's D and E were easy.

»
2 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I'm getting the wrong answer in 2 test cases in E. can anyone help me, why is it so? Thanks submission

  • »
    »
    2 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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.

»
2 года назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

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

  • »
    »
    2 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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$$$.

»
2 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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),...