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

Автор rng_58, история, 9 лет назад, По-английски

AtCoder Grand Contest 016 will be held on Sunday (time). The writer is sugim48.

Contest Link

Contest Announcement

The point values will be 300 — 700 — 700 — 1000 — 1400 — 1600.

Let's discuss problems after the contest.

UPD: Now the editorial (check page 5) is ready.

I'll add some quick comments here.

A.

Spoiler

B.

Spoiler

C.

Spoiler

D.

Spoiler

E.

Spoiler

F.

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

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

Why the writer is currently flying? The ICPC world final was ended.
Is this just copied the blog of AGC015? (Here)


UPD: I have more request! There is no upcoming contest!

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

Is there any feature to filter standings based on countries?

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

Auto comment: topic has been updated by rng_58 (previous revision, new revision, compare).

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

Does anyone have idea to mininum number of moves in D:XOR Replace?

I could find the necessary condition to transform a into b, but couldn't find the minimum number of moves. I guess, the minimum number of moves are either mismatches or mismatches + 1, but couldn't find their corresponding cases.

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

    The idea is very similar to that of Google CodeJam 3. The number of mismatches is indeed a lower bound, but you need to find minimum number of cycles to which you can decompose the swaps, and you can do that by union find. I wasted an hour by failing to understand how exactly is the N-th value (xor of all A values) play a role.

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

    Sometimes you need more moves. For example '4 1 2 5 6 2 1 6 5' needs 6 moves. Analyze why and you will find how to get the minimum number of moves.

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

    This was what I found in the contest :

    Reduce the problem to finding the minimum number of moves needed to turn an array a into b, where a move is swapping the last element with any other element of the array.

    Let the elements of array a be a0, a1, ..., an (an is equal to the xor of a0 to an - 1) and the elements of array b be b0, b1, ..., bn.

    Add an undirected edge from ai to bi for all i. Let x be the number of mismatches in the array a and b (not counting an and bn). For each component that does not contain an and bn and has size  ≥ 2, add 1 to the x. The answer is x.

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

A single testcase is worth 300 performance points ///

RIP rating (

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

Idea behind B ?

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

    Realize that the array has to be such that the difference between maximum and minimum values of the array is at most 1.

    Now there are two cases, either all the values of the array are same. That is only possible if all people have distinct color hats, or nobody has a distinct color hat.

    In the other case (when the difference is 1), let's assume the values are x and x+1, then all the people with value x must have a distinct color hat (i.e. each such person must have a color that no other person has). And for all the people with x+1, they should have a hat such that there is at least one other person, with value x + 1, that has the same color hat. Using this logic you will get an inequality. Code

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

How is it possible to consistently hold contests with such good problems :o?

Btw editorial doesn't work.

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

Now, tourist's rating is 3949, but in today's contest, he got 1st place.
I think his rating may become over 4000.


UPD: tourist's rating became to 4021. It will be one of the biggest record of AtCoder.

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

Auto comment: topic has been updated by rng_58 (previous revision, new revision, compare).

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

I tried F. The graph formulation of Sprague-Grundy is that we need to split the DAG into layers such that from each layer, we have edges to all layers below and vertices 1 and 2 are in the same layer, which can be done using a DP picking whole layers and all edges into them at once in . However, I'm getting a different result on the last test, consistent with checking by hand. Is that the whole right idea or am I forgetting something?

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

Was I the only one who had issues with problem C?

The checker was kinda strict, because difference between

cout << "No\n"; and cout << "No";

Cost me ~2-3 submissions and huge amount of time wasted

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

On E, a O(N2·M) solution optimized with bitset passed in 400ms. This is a bit sad (I did it this way, but I feel bad and feel like I hacked the problem).

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

For problem C, how do you prove that if H%h == 0 and W%w == 0 then the answer is No?

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

    You can partition the board into h × w disjoint rectangles. Each small rectangle has negative sum, so the total sum cannot be positive.

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

    Divide the entire board into H/h * W/w submatrices. Sum of each such submatrix must be negative whereas the whole some must be positive, so you get a contradiction. For example, if W=H=4 and w=h=2, you have:

    a[1][1] + a[1][2] + a[2][1] + a[2][2] < 0
    a[1][3] + a[2][3] + a[1][4] + a[2][4] < 0
    a[3][1] + a[4][1] + a[3][2] + a[4][2] < 0
    a[3][3] + a[4][4] + a[3][4] + a[4][3] < 0
    -------------------------------------
    add them all and you get sum of all the elements in the matrix is negative and it should be positive
    
»
9 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Can U explain me solution of problem B ?

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

For F it wasn't clear from limitations that you don't want solution in O(Bell(n - 2)·n2) to pass. Actually, I squeeze it through TL after the contest.

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

    I had O(Bell(n - 2)·n) and it passed easily in 2 seconds out of 5. Increasing n by 2 would disallow my solution, but this would imply setting TL to 10-15 seconds, which is not too great.

    EDIT: to be exact, my solution is O(Bell(n - 1)).

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

    Our bell solution took more than 20s, and we didn't want to make the constraints too tight for O(3^n * n) solution. But yes, we should have used bigger n.

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

    The TL was pretty loose IMO. My solution takes less than 200 ms and can be optimised further. It's O(N·3N), but treats vertices 1 and 2 as special, which improves the constant.

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

      Usually I don't like the idea "set constraints as high as possible". One of our solutions worked in 133ms, but at the same time poorly written O(3nn) C++ solution took 2s. And it doesn't look nice if the intended complexity is O(3n * n) and the TL is 1s for n = 15.

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

        For me, rule of thumb is "set the constraint as low as possible in order to not let slow solutions pass". This seemed to be pretty hard here, especially if you got Bell solution that took 20s.

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

        My rule of thumb is that a theoretically good solution should theoretically pass (if the contestant got lucky and the constant didn't end up too big), so a very poorly (10x) written solution taking 2s means the TL should be 2s like normal.

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

Our color/dan scheme is very systematic. The range of each color is exactly 400. We added silver crowns for 3200-3600, and gold crowns for 3600-4000. The range of each dan is exactly 200. This is something that never decrease (so we use the peak rating), and is used in Go or Shogi (Japanese chess).

I thought I carefully chose parameters such that reaching red in AtCoder is as hard as reaching red in TC or CF, and reaching 4000 is barely impossible for humans. However, tourist beat the rating system today. Congratulations!

Does anyone have an idea for new color/dan? Note that usually the highest "dan" is 10.

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

A safe strategy for tourist:

  1. Solve each tasks and test them well, but don't submit.
  2. When all tasks are solved, look at scoreboard, make sure no one solved all tasks. Submit all of them to win.
  3. If someone already solved all tasks, abandon this round and wait for next one.

Looks like this strategy only works at AtCoder? (And he indeed submitted all tasks after 1 hour in this round.)

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

Auto comment: topic has been updated by rng_58 (previous revision, new revision, compare).

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

Can someone give a detailed explanation on problem D? Still very confused.

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

    Reduce the problem to finding the minimum number of moves needed to turn an array a into b, where a move is swapping the last element with any other element of the array (if you have trouble here, see the current editorial)

    Let the elements of array a be a0, a1, ..., an (an is equal to the xor of a0 to an - 1) and the elements of array b be b0, b1, ..., bn.

    Do coordinate compression on these numbers and suppose there are v distinct numbers. Construct a graph on v vertices with the following method :

    Add an undirected edge from ai to bi for all 0 ≤ i ≤ n with ai ≠ bi. (We allow multiedges here)

    Each edge of this graph describes a mismatched pair. Note that each vertex has even degree, as if x appears k times in a, then it must appear k times in b. Thus, each component has an Eulerian cycle.

    Now, we can use these Eulerian cycles to construct the optimal solution. For the component containing an, we can perform the swaps according to the Eulerian cycle and use e - 1 swaps to accomplish the goal (where e is the number of edges in that component). After that, the last element will be bn and if the component containing bn is still unresolved, we can use e moves to resolve it, where e is the number of edges in that component. For every other component that does not contain an or bn, we require e + 1 moves to resolve that component. This summarizes to :

    Let x be the number of mismatches in the array a and b (not counting an and bn). For each component that does not contain an and bn and has at least one edge, add 1 to the x. The answer is x.

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

      Thank you for your clear explanation! Could you briefly prove that the constuction is optimal?

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

      " For the component containing an, we can perform the swaps according to the Eulerian cycle and use e - 1 swaps to accomplish the goal (where e is the number of edges in that component). After that, the last element will be bn and if the component containing bn is still unresolved, we can use e moves to resolve it".

      I had some difficulty understanding this part because I was unable to understand why an and bn would be in different components (if an is resolved, then so is bn). If an != bn, they are in the same component as there is an edge between them. If an = bn, they are in the same component as they are the same node. Could you perhaps explain your statement with a small example? :)

      I got AC adding e if an = bn, and e-1 if an != bn, where e is number of edges in the component of an.

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

        Ya I didn't realize an and bn are already guaranteed to be in the same component by construction of the graph :P. You're right, we should add e if an = bn and e - 1 if an ≠ bn for the component containing an.

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

Took me the whole day to fully understand problem D's solution. Worth it.

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

Can you please upload this round's testcases? Thanks in advance

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

I am getting verdict "IE" i.e Internal Error on my submission for Problem D. What does this mean?