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

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

We will hold TOYOTA SYSTEMS Programming Contest 2024(AtCoder Beginner Contest 377).

We are looking forward to your participation!

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

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

any Hint on how to solve $$$E$$$? Only hint

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

What was the intuition for E so that to move k steps we do 2^k-1 i = p[i] ?

I solved it but I kinda guessed it from the sample case and it took me a long time. The idea of 2^k-1 came to my mind from this :

When we do 1 move p[i] = p[p[i]] and p[p[i]] = p[p[p[i]]] , it seemed like number of moves would double each move. However this was a very vague idea and the problem kinda teased my brain , thats why it took me so long to solve the problem.

Here is my submission : https://atcoder.jp/contests/abc377/submissions/59187007

My Solution
  • »
    »
    2 года назад, скрыть # ^ |
    ← Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    The 2^k part is clear from the start, but how did you find the actual number of steps since 2^k is too big? I split p into cycles and solved for each of those independently, but it looks too complex, is there more elegant solution?

  • »
    »
    2 года назад, скрыть # ^ |
    ← Rev. 3  
    Проголосовать: нравится +3 Проголосовать: не нравится

    Basically the problem asks you to square the permutation $$$p$$$ $$$k$$$ times, so you are actually computing $$$p^{2^k}$$$. A cycle of size $$$s$$$ shifts by one each time you apply $$$p$$$ and after applying $$$p$$$ $$$s$$$ times you get back to the start, so applying $$$p$$$ $$$2^k$$$ times you have effectively to shift by $$$2^k \mod s$$$.

    Clarification about the notation: Permutations form a group under composition, so it is often convenient to use product notation for compostion of permutations. So with $$$p^n$$$ I mean $$$p \circ p \circ \ldots \circ p$$$, composing $$$n - 1$$$ times.

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

Someone look at the first place person's F submission: https://atcoder.jp/contests/abc377/submissions/59171780

They import sys like 8 times, comments in code, wrote 140 lines in 5 minutes.

Surely they will get banned right?

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

I enjoyed the problems, and I'm amazed at how surprising they turned out to be!

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

Problem E is great! At first, I thought it is just binary-lift, but later find that in fact we need find p[p[p[.....p[i]]]], where there are 2^k p[ ] operations. Thus, we can use dfs to find the period T of each i, and calculate R = 2^k mod T. Meanwhile, we also compute the "binary-lift" during the above dfs. Finally, the answer is p[p[p....p[i]]], where there are R p[ ] operations, which can be solved based on the above "binary-lift".

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

solved A-C

Tried to solve F using N-Queens logic, but ultimately got TLE

E was some disjoint graph cycle i think, will try to upsolve.

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

Is problem G well known, or classical?

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

Can someone explain how E [https://atcoder.jp/contests/abc377/tasks/abc377_e] can be solved.

I am not able to visualise it. I understood that if we apply permutation p on a sequence k times then how its changing. But if the permutation itself is changing then how the sequence is gonna change. Can someone help me understand it or point me to some relevant resource.

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

Does anybody have the derivation of that $$$P^{2^{k}}$$$ in problem $$$E$$$?

(I'm asking about derivation, not the proof by induction)