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

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

We will hold AtCoder Beginner Contest 335 (Sponsored by Mynavi).

We are looking forward to your participation!

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

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

I'm really curious, what is the purpose of running atcoder rounds right before codeforces ones? Warming up or anything else?

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

HELP, why this- Code submission gets TLE for problem E, any help is appreciated.

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

why no english editorial?

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

C was a nasty problem for its place. Much harder than D.

Also, how to solve problem E? I tried with bfs but got TLE in 15/95 test cases.

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

Why normal dfs with dp will not work for E if we only jump to node j from i if a[j]>=a[i]. My code for ref. Can anyone point out why is it failing?

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

What's the idea behind G?

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

C and D are both problems with stories of dragons. 2024 is the year of dragon.

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

help why my code is giving WA on 15 testcases on E? code link

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

hey does anyone have any idea on how to approach E , i tried dp on dfs , but cannot get uniqueness in the constraint time , gave me tle , does anyone have approach . It will be helpful. Thank you

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

Can anyone analyze the time complexity of my submission for F — Hop Sugoroku?

$$$dp[i]$$$ denotes the number of valid subsets of first $$$i$$$ elements such that the $$$i^{th}$$$ element is necessarily covered black. $$$dp[i]$$$ would contribute to all $$$j$$$ such that $$$j = i + a[i]*x$$$. So instead of iterating over all such $$$j$$$, I offload the increment for further indices to $$$j$$$ if I ever encounter $$$a[i] = a[j]$$$.

If there are no duplicates, then it works in $$$O(n \ log(n))$$$, but how to prove that it is still bounded by $$$O(n log(n))$$$ if there are duplicates?

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

    This solution is bounded by $$$O(N*sqrt(N))$$$ and mentioned in one of the editorial.

    On this case this soln prints 59528480 as no of operations. This is roughly $$$300*N$$$.

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

      That solution is brilliant. I'm still not understanding how the argument works for why it is definitely O(N * sqrt(N)) though. The proof is a bit mathematically concise in the editorial, wishing there was a more verbose proof with example.

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

        I read the example with 1,2,2,3,3,3,4,4,4,4... and I extended that pattern out to 200,000 elements, you get to something with ...,631. But what I observed is that each of those elements is visited 1,2,2,3,3,3,4,4,4,4... I believe. If you do this all the way out with 200,000 elements you get the ...,631. So for the worst case I get about 80 million iterations. And if you take N * sqrt(N) with N = 200,000 you get about 89 million. So I guess it is O(N * sqrt(N)) for that worst case. Still not to sure. This is just extending the worst case scenario introduced in the editorial. I don't have enough time to think about this for now though.

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

Is usage of __int128 intended in G?

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

I am getting TLE on problem E.Can anyone pleass help? My code.

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

    You should only apply DP on the leader nodes for each component. Here's a theoretical scenario that would TLE if not implemented properly.

    Consider a graph of $$$2 \cdot n$$$ vertices. Split all vertices into 2 equal groups.

    If you try to update the DP value of all nodes in the first group, you would have to take contribution from each of the $$$n$$$ nodes from the second group (since all of them are reachable). Hence, the time complexity is $$$O(n*n)$$$.

    The correct strategy is to populate the DP values of leader only. That is, instead of asking the best path from node $$$a$$$ in group 1 to node $$$b$$$ in group 2, ask about the best path from the leader of group 1 to the leader of group 2.

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

Can someone explain idea behind F

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

    Video Editorial for F : Hop Sugoroku

    Define $$$dp[i]$$$ to be the number of valid subsets of the first $$$i$$$ elements such that the $$$i^{th}$$$ element is necessarily painted black. The final answer is $$$\sum dp[i]$$$

    The transitions are trivial, just follow the rules mentioned in the problem, i.e, $$$dp[i]$$$ contributes to all $$$j = i + a[i] \cdot x$$$.

    Code

    What if the array was a permutation? Can you prove that the naive DP works in $$$O(n \cdot log(n))$$$?

    What if the array only consisted of $$$1s$$$? Do you see a way to optimize this DP? Note that each $$$i$$$ would update the suffix $$$[i + 1, \dots n]$$$. Hence, you can just use difference array to propagate the updates in $$$O(1)$$$. Hence, if you define $$$delta[i]$$$ to be the delta that needs to be pushed to the suffix, for each $$$i$$$, you can do $$$delta[i + 1] \mathrel{+}= dp[i]$$$. And you keep pushing that delta to the next element.

    What if the array only consisted of $$$2s$$$? You now have to update $$$[i + 2, i + 4, \dots n]$$$. The strategy from above still works. For each $$$i$$$, $$$delta[i + 2] \mathrel{+}= dp[i]$$$. But while pushing the delta, the delta from the $$$i^{th}$$$ element would be pushed to $$$i + 2^{th}$$$ element.

    What if the array only consisted of $$$3s$$$? What if the array had all elements equal to $$$z$$$? All of these individual cases can be solved in $$$O(n)$$$. So, if the array consisted of mixed integers, you can combine the same logic, now keeping a delta for each variable.

    Code

    Now, notice that the transitions are in $$$O(1)$$$. But the matrix size is huge. So, let's not maintain the delta values of $$$a[i] \gt \sqrt n$$$. Then, each time we encounter such $$$a[i]$$$, we can iterate over all its multiples and naively update the DP. Since $$$\sqrt n \cdot \sqrt n \geq n$$$, we would do no more than $$$O(\sqrt n)$$$ work for each such index. For the remaining $$$a[i]$$$, the delta value of variable $$$j$$$ would propagate from $$$i$$$ to $$$i + j$$$. Since $$$j \leq \sqrt n$$$, we can maintain a matrix of size $$$n \times \sqrt n$$$ to maintain these delta values.

    Code

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

time complexity of F is a bit strict i guess. my solutions execution time is 2.82 seconds but allowed time is 2.5 seconds.

this is my solution : https://atcoder.jp/contests/abc335/submissions/49137183

is there any way i could optimize this ?

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

For task G, the editorial says "Now, an (i,j) pair as in the problem statement is satisfactory if $$$k_j$$$ divides $$$k_i$$$ (to prove this, think of cycles and Bézout’s identity)." How to prove it?

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

What is difficulty rating of E,F on codeforces level

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

can anyone explain why my code for F is giving TLE ->https://atcoder.jp/contests/abc335/submissions/49152850

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

https://atcoder.jp/contests/abc335/submissions/49167270

My code fails for TC -41 for E can anyone tell error

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

Can anyone help me understand why my approach is giving WA in E?

https://atcoder.jp/contests/abc335/submissions/49224033

I just did plain dfs and maintained the max count.

Thanks in advance.

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

    Try this test case, it returns 3 when it should return 4. 5 5 1 2 3 3 4 3 4 1 3 1 2 2 4 3 5 I wrote out this example, it creates adjacency list [[3, 2], [1, 4], [4, 1, 5], [3, 2], [3]] => dfs traversal order: [1, 3, 4, 5, 2 ] [2, 1, min, 0, min

    It traverses the 1, 3, 4. And it places the vis = int_min, which prevents it from finding the optimal path later that is 1-2-4-3-5, instead it just finds 1-3-5. But if it is converted into a DAG by creating supernode (3, 4), then it will work. Because you can do DP on a DAG.