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

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

We will hold AtCoder Regular Contest 137.

The point values will be 300-400-600-700-800-1100.

We are looking forward to your participation!

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

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

looking forward to participate! also friendly bump as it will begin in 15 mins

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

C++20 when

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

Looking forward to enjoy the contest!

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

What happened to the country leader-board ?

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

400 points questions in ARC are much harder than 400 points questions in ABC.

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

is D sos-dp?

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

    Apparently, but it also has a cool serpenski triangle-like structure that leads to a simple $$$O(n logn)$$$ recursive solution.

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

      Can you explain how to use this diagram? Because I found it too during the contest, but don't know how to make it $$$n\log n$$$.

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

        Let $$$solve(i, k)$$$ be a vector of size $$$2^k$$$ that represents the effect of applying a $$$2^k$$$-length leg right triangle to $$$i-2^k+1, ..., i$$$ (ie. the right angle would be at $$$i$$$). This equals $$$[solve(i, k-1)+solve(i-2^{k-1}, k-1), solve(i, k-1)]$$$, where $$$[a,b]$$$ means vector b appended to vector a and $$$a+b$$$ implies element-wise xor.

        Here's my code if it helps: https://atcoder.jp/contests/arc137/submissions/30246718

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

I've never seen a prime gap in my life. Dang it.

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

Solved D 2 minutes after the contest... I can't believe myself

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

I've always been a fan of ARC, but isn't today's problem a bit standard? D is Lucas theorem and the high-dimensional prefix sum, and E is the maximum cost cyclic flow. Of course they are fine as standard problems, but I feel that this is a departure from ARC's past style. C is very beautiful though. Anyway thanks to the author for bringing us this contest.

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

    I think E is quite annoying that even if you figure out how to make the graph, you can't get accept without using primal-dual algorithm, which is not often used in cp.

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

      If the initial graph is a DAG or has no negative edge ,then the min cost flow can be solved in O(flow*N*log(n)) using Dijkstra. I think it is not rare in cp.

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

      You can use the Atcoder Library.

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

      can anybody explain me primal-dual algorithm is how being applied to this problem? Since I don't know about primal-dual, I read some articles(googled them) for primal-dual, but I couldn't understand how this problem is being interpreted as so.

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

Maybe it's better to mark the key word such as " largest element" in problem C.It would help those whose English isn't so good(such as me) a lot.No matter how, thanks for the good contest.

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

    You are right. I WA on C for 10+ times because of it, and got AC quickly after the contest.

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

spent too much time on A trying to figure out what number theory tool to use only to find out its brute force.

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

I was able to solve Task A during the contest purely based on intuition, but haven't been able to prove it.
I am trying both L and L + 1 as x and finding the largest co-prime numbers for them to maximize the value of y - x.
My Submission.
It would be great if someone could help with the proof of this approach.
Thanks.

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

I got TLE in E because of my big constant, I realize the importance of making a good template.

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

Solve D in an optimize brute force which time complexity is $$$3^{10} \times 2^{10} + 3^{10} \times 2^{10}$$$ https://atcoder.jp/contests/arc137/submissions/30258055

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

Both C and D can be done by brute force + finding the pattern.

For C, we can brute force all array A such that $$$A_N \leq K$$$, say, $$$K = 10$$$. Actually, by the basics of game theory (Bob wins when all next cases Alice can win, Alice wins when any next case Bob can win), the brute force can be easily done by a bitmask DP. After this bruteforcing, we can easily find the pattern.

For D, we want to find which initial $$$A_i$$$-s contribute to $$$A_N$$$ in the $$$k$$$-th round. It's easy to see there's a cycle for $$$A_N$$$ among rounds, so we want to find the length of this cycle, and how each element in this cycle is composed. To check for whether an initial $$$A_i$$$ contributes to $$$A_N$$$ in the $$$k$$$-th round easily, we can set $$$A_i = 2^{i-1}$$$ initially, and check the $$$i$$$-th bit of $$$A_N$$$ in $$$k$$$-th round. After bruteforcing, we find that for $$$2^{c-1} < N \leq 2^c$$$, the length of $$$A_N$$$'s cycle is $$$2^c$$$, and if $$$N_1<N_2$$$, elements in $$$A_{N_1}$$$'s cycle are prefixes of $$$A_{N_2}$$$'s cycle. This inspires us to complement the length of $$$A$$$ to $$$2^c$$$. Then we can look at some cycles ($$$A_N$$$ in binary representation) and find the pattern:

$$$N = 4$$$, the cycle is 1000 1111 1010 1100;

$$$N = 8$$$, the cycle is 10000000 11111111 10101010 11001100 10001000 11110000 10100000 11000000;

$$$N = 16$$$, the cycle is 1000000000000000 1111111111111111 1010101010101010 1100110011001100 1000100010001000 1111000011110000 1010000010100000 1100000011000000 1000000010000000 1111111100000000 1010101000000000 1100110000000000 1000100000000000 1111000000000000 1010000000000000 1100000000000000.

And it's easy to see the pattern by splitting the binary representation into two halves. According to this pattern, we can come up with a $$$O(n \log n)$$$ solution based on divide-and-conquer.

I have included the bruteforcing code in annotations of my solution.

C: https://atcoder.jp/contests/arc137/submissions/30247609

D: https://atcoder.jp/contests/arc137/submissions/30242515

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

Can any one please explain how to solve C? I couldn't understand the editorial at all.

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

    Assume a[n] > a[n — 1] + 1. After the first move you can reach some positions (i. e. states of the array, this is obvious), call them p1, p2 .. pm. In particular you can move a[n] -> a[n] — 1, call this position pm. Now if any of (p1, p2 .. p_m-1 is losing you could move directly there and win. If not, it means that p_m is losing since from there you can only move to p1, p2 ... p_m-1 (all of which are winning). Hence if a[n] > a[n — 1] + 1 first player always wins. Now assume it's not the case. Players will alternate in moves, but note that you can never allow the situation, where after your move the biggest element is bigger than the second by at least 2 -> then it would mean that you just let opponent win, by the argument from the begginging. It means that all "gaps" in the array (numbers >=0 && <= a[n] that are not present in original array a) must be visited. So now parity of the number of gaps decides who will be the winner.

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

What's the meaning of "Repeated applications of one-dimensional prefix sum correspond to vertical and horizontal moves in a two-dimensional grid" in the editorial of Problem D?

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

    If you focus on the contribution of a single element when doing prefix sum multiple times, you will find out that stuff is similar to path on grid

    ex.

    1 0 0 0

    1 1 1 1

    1 2 3 4

    1 3 6 10

    (4 is C(4, 1), 10 is C(5, 2) etc...)