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

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

We will hold AtCoder Beginner Contest 308.

We are looking forward to your participation!

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

»
13 месяцев назад, # |
  Проголосовать: нравится +108 Проголосовать: не нравится

is this account legit? maroonrk

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

Problem were relatively easy this time especially F and G. Nice round.

»
13 месяцев назад, # |
  Проголосовать: нравится -6 Проголосовать: не нравится

Can C be solved by using modulo inverse?

»
13 месяцев назад, # |
  Проголосовать: нравится +19 Проголосовать: не нравится

You can use trie to do G right?

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

    just simple set will do the trick.

  • »
    »
    13 месяцев назад, # ^ |
      Проголосовать: нравится +3 Проголосовать: не нравится

    It can be done with a multiset.I'm not sure how to do it with trie.

  • »
    »
    13 месяцев назад, # ^ |
      Проголосовать: нравится +3 Проголосовать: не нравится

    No, using multiset.

  • »
    »
    13 месяцев назад, # ^ |
      Проголосовать: нравится +11 Проголосовать: не нравится

    Yes, I solved it with divide and conquer + trie.

    At first I completely misunderstood the problem and started thinking in wrong direction, but still it is interesting approach I think.

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

      Curious to know your approach. Can you explain it?

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

        He probably used segment tree. You see, the problem would be trivial if the "remove" query was a "roll-back" query. So the idea is just the same as dynamic connectivity. The complexity is $$$O(N * log ^ 2 N)$$$, which is not too bad considering the time constraint is $$$3$$$ seconds

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

          Ok explain then, my tiny brain can't comprehend dynamic connectivity

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

        We notice, that writing $$$x$$$ on the blackboard and erasing $$$x$$$ from the blackboard means that $$$x$$$ is spanned on some segment of queries, so we can use similar trick that we use in offline dynamic connectivity.

        With a segment tree add $$$x$$$ on some range and when you traverse the segment tree recursively you want to do following:

        • Insert $$$x$$$ in a trie.
        • Find minimum $$$y$$$ $$$xor$$$ $$$x$$$.
        • Roll back all the inserted nodes from trie.

        All of this can be done in $$$O(N*log(N)*log(x))$$$

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

          I have a better approach.

          Make each node of the trie, store the answer for the suffixes of all the numbers that are in its subset (sub-tree or sub-trie, whatever). The idea is something similar to the merge operations we do in segment trees. Every time we insert or delete a number, we update the answer for all the nodes that are affected by its insertion or deletion. This works in O(NlogN). Here is a link to my submission: link

          PS: But, it feels really silly to use a trie for this problem after reading the editorial.

          • »
            »
            »
            »
            »
            »
            13 месяцев назад, # ^ |
              Проголосовать: нравится +3 Проголосовать: не нравится

            "PS: But, it feels really silly to use a trie for this problem after reading the editorial."

            Don't worry, it might be useful for other hard problems in future.

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

    I did using a set, Code

    The main idea is that it suffices to check every adjacent elements in a sorted array to get the minimum Xor

  • »
    »
    13 месяцев назад, # ^ |
    Rev. 2   Проголосовать: нравится +19 Проголосовать: не нравится

    Yes, I solved it with dp on trie, using the fact that when we add/remove a number, at most 30 nodes need to recompute their dp value. Here is the code :)

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

      Can you elaborate a bit about dp state and you idea?

      • »
        »
        »
        »
        13 месяцев назад, # ^ |
          Проголосовать: нравится +8 Проголосовать: не нравится

        The problem asks to find two paths to leaves of the trie with minimum xor value. We compute the dp value for each node, assuming that both paths go through it. Answer is the value of the root.

        If a node has two possible paths when adding a 0 (or a 1), it’s never optimal to choose one path with 0 and the other one with 1.

        We are left with the case when there is only one path with 0 and one with 1. Given that each path the only one in its subtree, we can mantain the value of the number it represents and use it to compute the xor of the two possible paths (we can update this value when we add/remove numbers).

        Refer to my code for more details :)

»
13 месяцев назад, # |
  Проголосовать: нравится +6 Проголосовать: не нравится

Hints for E,F,G please :)

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

Can anyone explain the DP soln for F?

»
13 месяцев назад, # |
  Проголосовать: нравится +6 Проголосовать: не нравится

Lmao, I finished F like 10 minutes after the contest was over and F took me less time than any of C-E.

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

.

»
13 месяцев назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

In the editorial of G, shouldn't it say "more significant bits" instead of "less significant bits"

»
13 месяцев назад, # |
  Проголосовать: нравится -8 Проголосовать: не нравится

Why E requires DP, but F only requires greedy?

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

https://atcoder.jp/contests/abc308/submissions/43142095 can anyone tell me whats problem here 4/39 case are failing i am not able to figure out problem wasted a hell lot of time in this done E late but haven't solved D

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

    check line 10.

    Also dp is redundant, It does nothing here plus format your code. It's a headache to read.

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

Can someone please tell why I am getting runtime error on problem D. I have used simple DFS with dp, some pass but mostly give me Runtime error. https://atcoder.jp/contests/abc308/submissions/43178624

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

    you are visiting the same nodes again and again

    it will give run time error for this case

    2 6

    sekunf

    nukesn

    first you will start at (1,1) you will reach (2,5) from there one dfs will be to (2,6) and another to (1,5)

    consider (1,5), you will again go to (1,1) but at(1,1) dp[1][1] will still be equal to -1 as the dfs from (1,1) is not completed fully so you will again start dfs from (1,1) and it goes on .