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

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

1345A - Puzzle Pieces

Tutorial

1345B - Card Constructions

Tutorial

1345C - Hilbert's Hotel

Tutorial

1345D - Monopole Magnets

Tutorial

1345E - Quantifier Question

Tutorial

1345F - Résumé Review

Tutorial

1344E - Train Tracks

Tutorial

1344F - Piet's Palette

Tutorial
Разбор задач Codeforces Round 639 (Div. 1)
Разбор задач Codeforces Round 639 (Div. 2)
  • Проголосовать: нравится
  • +586
  • Проголосовать: не нравится

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

Thank you for great round and fast editorial

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

There is a typo in the editorial for D2C/D1A.

"This proves there is a collision if and only if all i + a_i are distinct" should be "This proves there is no collision if and only if all i + a_i are distinct".

UPDATE: It has been fixed, but in a way different from what this comment indicates. Please read carefully before making further downvotes.

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

I feel really sorry for the problemsetter.. He must have worked hard to create those problems..also this was his first round as a setter..

The problems were great, thanks a lot :) :)

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

I've read the problems and they're indeed very interesting. I congratulate you and thank you for your work, and really feel sorry about the issues that made this contest unrated.

I want to leave an idea that has been growing on my mind. I think that given the fact that there are much fewer Div. 1 contests than Div. 2 or Div 3., in the case of "long queue" issues, one should give a priority to the judgement of Div 1. submissions.

I know that if one interprets this as if it was "Div. 2 doesn't matter", it doesn't sound so nice. However, I think that there are much fewer participants in Div. 1 and it may be possible to at least try to "save that contest" when this issues occur.

Only that. A suggestion.

Cheers,

Roberto Esquivel Cabrera.

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

tbh kind of disappointed with it going unated...tried so hard and finally got the 2nd question right after a hour.

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

what will be the quadratic formula for B?

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

loosed +160 delta

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

The problem set was really nice, looking forward for more rounds from you.

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

I am totally confuse dev2 A question.... Plz somebody plzz help me....

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

    In this problem, when you take 2*3 grid you see that you can not solve that puzzle, therefore you can not solve similar grids which has higher dimensions than 2. That means, if either row or column is 1 it can be sokved and if both are 2 it can be solved. Otherwise not. I hope now you understand.
    Sorry for my bad english..

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

Really great round but I am sad for this nice problem became unrated.

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

For F, I went with a much more natural approach to me, where for each position we have 4 variables $$$r_i, y_i, b_i, e_i$$$ (I hope their meaning is clear, e.g., $$$r_i=1$$$ if i-th position is red). YB operations etc are basically swapping variables. Since result of each mix operation is white if all colors occur with the same parity and a proper color if one of them has a different parity than the others two, each mix operations produces 2 equations modulo 2 corresponding to the difference between parities of some two colors. However we have a nasty condition that exactly one out of $$$r_i, y_i, b_i, e_i$$$ should be 1 that can't really be expressed modulo 2, which seems like a big problem. However, what happens if we put there an equation $$$r_i+y_i+b_i+e_i=1$$$? We can get a faulty solution where $$$3$$$ out of these bits are lit. BUT, this system of equations has a very peculiar property that for every $$$i$$$, every equations contains an even number of variables $$$r_i, y_i, b_i, e_i$$$, so if we flip all of them then this will still be a solution! Hence if 3 of these variables are true then we can change them so that 1 of them is true and if we do this for every $$$i$$$ where it is needed then we will get a solution of equation system corresponding to the valid coloring!

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

The setting of 1344C - Quantifier Question is very nice. Thank you for the problemset!

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

Can somebody explain div2C, I can't get my head around the proof ?

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

    consider a subset of rooms, from room 0 to n-1. let n = 5. CASE 1 let's assume a0 = 0, a1 = 1, a2 = 2, a3 =3, a4 = 4. Now, the guest in room 0 will go to -> 0 + a0 = 0 similarly guest in room 1 will go to -> 1 + 1 = 2 room 2 -> 2 + 2 = 4; room 3 -> 3 + 3 = 6; room 4 -> 4 + 4 = 8;

    room 5 -> 5 + 0 = 5; room 6 -> 6 + 1 = 7; room 7 -> 7 + 2 = 9; room 8 -> 8 + 3 = 11; room 9 -> 9 + 4 = 13; .... and so on.

    No guests get the repeating room {explained later}

    CASE 2 let's consider a0 = 5, a1 = 7, a2 = 5, a3 = 8, a4 = 6; for room 0 -> 0 + 5 = 5; room 1 -> 1 + 7 = 8; room 2 -> 2 + 5 = 7; room 3 -> 3 + 8 = 11; room 4 -> 4 + 6 = 10;

    room 5 -> 5 + 5 = 10; {gets repeating room} ******

    in both cases, we can observe an arithmetic progression is forming . after every n__

    Now if we observe both the cases, we can see that if, for a particular value of 'i' b/w 0 to n-1 if there exists a j, such that aj + j lies in the arithmetic progression of (ai + i), it implies that there will be a collision. This is because, a time will come when becomes (aj + j),

    for example in case 2,

    for i = 0 we can see that ai = 5 and i = 0; so the first term of the arithmetic progression is ai + i = 5 + 0 = 5; now we'll check for j = 1 to n-1, whether there is such a j for which aj + j lies in the arithmetic progression of ai + i with difference = n; so for j = 4, aj = 6, and aj + j = 10; so aj + j clearly lies in the arithmetic progression of ai + i ( 5 + 1*5 = 5) {ai + i + (x-1)*n = xth;}

    this way we have to check for every i, that, whether there is a number which is in ap with ai + i and diff = n; this will take O(n*n). To optimize it we can just check whether there are more than one such numbers such that (ai+i)% n == (aj+j) % n because ai + i + (x-1)*n = aj + j; taking modulo both sides we'll end up with (ai+i)% n == (aj+j) % n and hence O(n).

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

      Thanks a lot!! just one thing that arithmetic progression of n also means that one should also be a multiple of other. So we just need to check if the taking the mod of (i+a[i]) gives same value as any other index.

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

        suppose we take n =3, a0 = 0, a1 = 1, a2 = 2; room 0 -> 0 + 0 = 0

        room 1 -> 1 + 1 = 2

        room 2 -> 2 + 2 = 4

        room 3 -> 3 + 0 = 3

        room 4 -> 4 + 1 = 5

        room 5 -> 5 + 2 = 7

        room 6 -> 6 + 3 = 9 ........ and so on

        therefore room0, room3, room6, room9.....are in ap

        similarly, room1, room4, room7, room10 ..... are in ap

        and room2, room5, room8 .... are in ap

        if any of the rooms in 2nd and 3rd row in this example are common with any room in first row {means are present in ap of first row,} Collison will occur. similarly if any rooms in 3rd row are common with any room in second row {means they are present in ap of 2nd row.} Collison will take place.

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

        yes

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

      This comment is by moha.jain credit to him for the explanation. and I re-wrote it to make it more readable.

      Consider a subset of rooms, from room $$$0$$$ to $$$n-1$$$. let $$$n = 5$$$.


      CASE 1: let's assume $$$a_{0} = 0$$$ , $$$a_{1} = 1$$$, $$$a_{2} = 2$$$, $$$a_{3} = 3$$$, $$$a_{4} = 4$$$. Now, the guest in room $$$0$$$ will go to $$$0 + a_{0} = 0$$$ similarly guest in room $$$1$$$ will go to $$$1 + 1 = 2$$$ room $$$2$$$ go to $$$2 + 2 = 4$$$; room $$$3$$$ go to $$$3 + 3 = 6$$$; room $$$4$$$ go to $$$4 + 4 = 8$$$;

      room $$$5$$$ go to $$$5 + 0 = 5$$$; room $$$6$$$ go to $$$6 + 1 = 7$$$; room $$$7$$$ go to $$$7 + 2 = 9$$$; room $$$8$$$ go to $$$8 + 3 = 11$$$; room $$$9$$$ go to $$$9 + 4 = 13$$$; .... and so on.

      No guests get the repeating room explained later


      CASE 2: let us consider $$$a_{0} = 5$$$, $$$a_{1} = 7$$$, $$$a_{2} = 5$$$, $$$a_{3} = 8$$$, $$$a_{4} = 6$$$; for room $$$0$$$ go to $$$0 + 5 = 5$$$; room $$$1$$$ go to $$$1 + 7 = 8$$$; room $$$2$$$ go to $$$2 + 5 = 7$$$; room $$$3$$$ go to $$$3 + 8 = 11$$$; room $$$4$$$ go to $$$4 + 6 = 10$$$;

      room $$$5$$$ go to $$$5 + 5 = 10$$$; gets repeating room


      In both cases, we can observe an arithmetic progression is forming . after every $$$n$$$

      Now if we observe both the cases, we can see that if, for a particular value of $$$i$$$ b/w $$$0$$$ to $$$n-1$$$ if there exists $$$a_{j}$$$, such that $$$a_{j} + j$$$ lies in the arithmetic progression of ($$$a_{i} + i$$$), it implies that there will be a collision. This is because, a time will come when becomes ($$$a_{j} + j$$$).

      For example in case 2:

      for $$$i = 0$$$ we can see that $$$a_{i} = 5$$$ and $$$i = 0$$$; so the first term of the arithmetic progression is $$$a_{i} + i = 5 + 0 = 5$$$; now we will check for $$$j = 1$$$ to $$$n-1$$$, whether there is such $$$a_{j}$$$ for which $$$a_{j} + j$$$ lies in the arithmetic progression of $$$a_{i} + i$$$ with difference equals to $$$n$$$; so for $$$j = 4$$$, $$$a_{j} = 6$$$, and $$$a_{j} + j = 10$$$; so $$$a_{j} + j$$$ clearly lies in the arithmetic progression of

      $$$a_{i} + i$$$ ($$$5 + 1 \times 5 = 10$$$) => $$$a_{i} + i + (x-1)\times n$$$ $$$=$$$ $$$xth$$$

      this way we have to check for every $$$i$$$, that, whether there is a number which is in ap with $$$a_{i} + i$$$ and $$$diff = n$$$; this will take $$$O(n \times n)$$$. To optimize it we can just check whether there are more than one such numbers such that

      $$$(a_{i}+i)$$$ $$$mod$$$ $$$n$$$ $$$\equiv$$$ $$$(a_{j}+j)$$$ $$$mod$$$ $$$n$$$

      because $$$a_{i} + i + (x-1) \times n = a_{j} + j$$$; taking modulo both sides we'll end up with $$$(a_{i}+i)$$$ $$$mod$$$ $$$n$$$ $$$\equiv$$$ $$$(a_{j}+j)$$$ $$$mod$$$ $$$n$$$ and hence $$$O(n)$$$.

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

      I solved by your approach but getting the wrong answer. Can you please tell me where am I wrong? https://codeforces.me/contest/1344/submission/79319693

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

    Consider the number line divided into segments of size n i.e [-1*(n) -2 -1] [0 1 2 ...n-1] [n n+1 n+2...2*n — 1] so now when you add to i + a(imodn) each i converts to some j which will be a index of one of these segments definitely.. What i am trying to say is that.. For example 1)n==3 Consider applying shuffling operation of segment [0..2] and we have a1,a2,a3 such that after shuffling 0->3,1->7,2->11 now 3 is actually at 0th position in its segment [3,4,5] 7 at 1st in [6,7,8] and 11 at 2nd position in [9,10,11] so in this example above we can see that each element results into an unique positions ,whatever be the segment it settles

    So for such kind of example always the answer is YES!!

    But consider this example

    2) n==3 and we have a1,a2,a3 such that 0->3,1->6,2->11 so now 11 is still the 2nd position but 3,6 both are ones at 0th position Therefore such array a will result in generation of elements in which no 1st position element is ever created but the 1st position elements get converted to 0th position So Vacancy will be definitely created.. So for such kind of example the answer is NO!! * HOPE YOU UNDERSTAND..

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

    I know it's late but I think this is easier (it might help someone)
    We know that a collision occur if for some $$$0 \leq i,j \leq n-1 $$$ where $$$ i \neq j$$$, the following condition holds true
    $$$ i + k_1n + a_i = j + k_2n + a_j$$$ because $$$x+yn \equiv x \mod n$$$ where $$$0 \leq x \leq n-1$$$
    Now, $$$i+a_i-j-a_j = (k_2-k_1)n$$$
    $$$ \implies i+a_i-j-a_j \equiv 0 \mod n$$$
    $$$\implies i+a_i \equiv j+a_j \mod n$$$

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

Can anyone explain why all numbers being distinct will not affect values of k>n?

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

Can someone explain C again?

The shuffle isn't k + a[k mod n]?

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

Solved 3 problems before round was announced to be unranked. Never started that good :(

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

The decision of making this round unrated is highly appreciable. Many of us waited to check if our solution was correct before solving a new one. Feeling sorry for the problem setter/s. He/they must have worked so hard but a bug ruined all. Hope mike will find a way through this.

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

Can someone explain E in simpler terms? The concept of topological sorting is confusing me here. I understood the part of the graph being acyclic, but didn't get what they did next.

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

    Topological sorting isn't needed in this problem. The idea is, look at the numbers from a_1 to a_N in order. When you get to an index k, how do we know if we can put an A there? It's only possible if a_k is "not comparable" to any other a_i where i<k. So my solution is whenever we process an index i, we do two dfs traversals — one to mark all indices j where a_i<a_j, and one to mark all j where a_j<a_i.

    This way, when we get to a_k, we checked if it was marked in one of the two ways. If it was marked, we have to put an E at k. If it wasn't marked, we put an A. In either situation, we do the two traversals.

    In order to keep track of this, I kept two "seen" arrays — one array to mark seen vertices when going "up" the graph, and one for going down. As a result the solution was very clean.

    I also checked for cycles in the same traversal, but you don't need to do that if it's too confusing — you can do it in a separate pass.

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

Div 2 C

Example:

3

3 2 1

In the fourth test case, guests 0 and 1 are both assigned to room 3.

2

0 1

In the test case, guests 1 and 2 are both assigned to room 2.

Why we have guest 2? I see only 2 rooms — 0 and 1. If k=0 and n=2, k+a[k mod n]=0+a[0]=0, so guest 0 still sit in room 0. And other guest assigned to room 2. Where is my mistake?

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

    Read the problem statement carefully. There are infinite rooms.

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

      guests 1 and 2 are both assigned to room 2 It means, that we have 3 guests: a[0],a[1],a[2], but at the beginning we have only a[0] that will be assigned to room 0 and a[1] that will be assigned to room 2.

      Each of the two guests has their own room so we must return YES, but in example true answer in NO,because extra 3rd guest are in room 2 with guest 1

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

        in fact,we can assume that we have infinite room,each room contain a guest at the beginning.(we could think that there are infinite guests as well},so once we use the constraint to re-organize the position,all of the guest (infinite of course) will change there position by k+a[k mod n].so the example is ok whatever

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

Can someone help me in figuring out why Div2D test 50 fails? Seems like I'm counting connected components incorrectly, but I can't seem to figure it out.. .

https://codeforces.me/contest/1345/submission/79197607

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

In div2 E, let's say we add egde from j's->k's(in_degree[j's]++. Assuming resulting graph is acyclic then we can make those vertices as universal if their in_degree is equal to 0. Can someone tell me what's wrong with my logic? Below is the link to my code. https://codeforces.me/contest/1345/submission/79209006

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

For Div2.C, I tried a (supposed) N^2 solution and it got accepted: https://codeforces.me/contest/1345/submission/79212988 I suppose it can be proved that it will never actually do so many iterations. Otherwise, maybe test cases are not strong enough.

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

Does anyone know why in div1C,the answer of the testcase below: 3 2 1 2 3 2 is 1 AEE ?

shouldn't it be 2 AEA???

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

In the sol. for Div2E/1C, I don't understand this

For each variable, we can find the minimum index of a node comparable to it by doing DP in forward and reverse topological order.

Please explain this.

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

Dang, I really like Div2F. I had the right idea for it but didn't implement because I thought it was wrong and it was unrated anyways.

Great problems...too bad there were technical difficulties.

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

Started well off however for some reason, for div2D my submission solves all the test cases correctly on my IDE however does not seem to even get the correct answer for the very first test case when I submit it to the online judge. Any help would be appreciated — cheers

https://codeforces.me/contest/1345/submission/79218763

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

    I get two warnings when compiling that, both which might lead to undefined behavior (I got the answer 6 when running it on my computer). One is that size is ambiguous (size is a std function you included) and the second is that k isn't initialized. I compile with -Wall -Werror -Wpedantic (and I have it so Vim + YouCompleteMe highlights such errors).

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

can someone tell why is this not optimal solution Question D div 2

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

Poor Monogon.But the problems are really great.Thanks!

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

I think there is something wrong with the Div2 C for it's type. $$$(k+a_k){\bmod n}$$$ instead of $$$k+a_{k\bmod n}$$$

And does anybody tell me why k is in[0,n — 1]?

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

I had the right idea for Div2 C. Not sure where my error is, I'm pretty sure this checks if all the rooms are distinct, and it works for almost all the test cases, but fails on a couple for some reason...

http://codeforces.me/contest/1345/submission/79207288

Any help would be appreciated.

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

    Fixed your code the number you module is negative,which may cause problems

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

      Thank you! That was in fact the problem. I fixed it by replacing the insert line with

      toAdd += j; toAdd %= n; if(toAdd < 0) toAdd += n; a.insert(toAdd);

      I'm still a little confused though, because I thought my conditional (toAdd + j < 0) ? ((toAdd + j) % n) + n : (toAdd + j) % n took care of negatives. I'm new to C++ so maybe I'm misunderstanding what that expression does or how the % operator works. How was it possible for my previous code to return a negative mod?

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

        % doesn’t do the mathematical mod, it does remainder. you have to add in the modulus to get it to be the mathematical modulus.

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

          What do you mean by add in the modulus? Isn't n the modulus there? Sorry I'm a little new to programming lol.

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

            The modulus is the number that you're "modding" by. It's like the divisor in division; when you do $$$15\ /\ 5$$$, you call $$$5$$$ the divisor.

            What I mean by adding it in, is consider $$$-9\ \%\ 5$$$. The result of this expression in C++ is $$$-4$$$, but in math terms, what we want is $$$1 \equiv -9 \pmod{5}$$$. So what we can do, is when we can add $$$5$$$ to the original expression (that resulted in $$$-4$$$) to get what we want, which is $$$1$$$.

            Basically, if you want to compute $$$a \pmod{b}$$$, where $$$a$$$ can be negative, you write ((a % b) + b) % b

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

              But the expression a % b only returns the wrong value if a is negative, right? So if I have the conditional (toAdd + j < 0) ? ((toAdd + j) % n) + n : (toAdd + j) % n it checks if a is negative (in this case a is toAdd + j), and returns the bolded part where I do in fact add n (the modulus). If it's not negative I don't need to add it, I think. I'm still slightly confused. But thanks for your help!

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

    Like this? 79238791.

    I guess the problem is toAdd + j can't be negative, which makes the statements behind that meaningless.

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

Div2E/Div1C:
WA on pretest 5 -
I tried my to make a directed graph and check for a cycle. If it is acyclic, if some vertex has non-zero indegree, I give it an E, else it has an A. What is wrong with this logic? https://codeforces.me/contest/1345/submission/79197644

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

So unfortunate that the contest had to be unrated. The problems felt good and interesting. Hope the problem gets fixed today

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

In Div1B/ Div2D, why can't we fill all cells with South pole? Monogon

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

I think it's better to add a link below the contest announcement. Just personal advice.

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

I don't understand this statement. Please help me.

"For each variable, we can find the minimum index of a node comparable to it by doing DP in forward and reverse topological order. Then for every variable not comparable to a smaller indexed variable, let it be universal. All other variables must be existential. Our requirement of universality proves this is optimal."

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

    I'm assuming you are familiar with the application of dynamic programming on DAG. First, you need to find a topological sort of the graph (it exists only if the graph doesn't contain any cycle). Now do a forward traversal on the topological sort and for every value 'i' calculate the minimum value of the node that appeared on a path that ends at vertex 'i' (while moving forward). This can be calculated easily by DP. Now do a backward traversal on the topological sort (also reverse the edges) and separately calculate the minimum value of the node that appeared on a path that ends at vertex 'i' (while moving backward). Now for each node, you have the minimum value of the node that is somehow connected to this node. If this minimum value is less than the value of the node then you cannot assign a universal quantifier to the node (let's say a node is 2 and the min value is 1, then either x1 < x2 or x2 < x1. In either case you cannot assign A to 2), otherwise you can assign the universal quantifier to this node. See 79647809

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

https://codeforces.me/contest/1345/submission/79177038 I got wa in this and it gets accepted as soon as I put (n+(i+a[i]%n))%n here https://codeforces.me/contest/1345/submission/79242347 can anyone tell me why is that I mean n+(i+a[i])%n should always give the same value as (n+(i+a[i])%n)%n can anyone help me with this

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

Is it only me or did someone else also found div2C confusing? I loved the question but took me a long long time to decode the meaning.

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

can any one help me out why i am getting wa on 17th test case??

79245621

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

I am not able to find the error in my solution for 1345D. My Solution Link = https://codeforces.me/contest/1345/submission/79249181

It is giving WA on test 17 Please Help Thanks

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

can someone explain me fifth test case of input given at div2 C problem. How the first and second guest are having the same room no. 2 after suffling?

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

I got stack overflow error in Div2D during the contest, then I tried using thread as I read it somewhere. That too isn't working for me.Maximum recursion depth in my code is 10^6. Can anybody tell me how to resolve this in java!

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

Div2 C detail explanation with example and code here in case anyone need :)

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

Why is this MLE? Monogon

Isin't the answer same as the editorial : 79185068

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

Div2F ai−3x2+3x−1!=ai-3x(x+1)-1 but why do work ai-3x(x+1)-1?? anyone help please

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

Can someone please explain div 2 problem F?

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

https://codeforces.me/contest/1344/submission/79310940 (1345D Monopole Magnets)

Does anyone know what exit code -1 means? I'm not sure what is causing the runtime error. Please help. I seem to be outputting the correct answer so I am very confused.

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

For the problem — Monopole Magnets, it is written:- "every row and every column has exactly one segment of black cells or is all-white"

From what I'm understanding, there should be continuous black cells within a row or a column. No white between them.

So, if I have a 3x3 square with the middle cell (1,1) white and all other cells black. Then I can have a solution with four south magnets at the four corners ((0,0), (0,2), (2,0), and (2,2)).

Can anyone tell me if it's correct or I'm making some mistake?

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

Thanks for the great contest And yes, feeling sad for Monogon as this contest became unrated. Sorry for the comment. BUT Am i the only one who got think the problem div2C was written wrong? As it was written in problem that guest in room k will be shifted to room k+a[k mod n] but after seeing the tutorial, i come to know that it should have been ((k+a[k]) mod n). Sorry for poor english. Plz reply Monogon

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

In Div2F/ Div1D Resume Review Problem, """Simply binary search on the value of A so that we increment exactly k times""". How exactly the binary search is giving us the optimal solution? Can anyone please explain it with some example testcases?

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

    You can think of it as what is the minimum increase we are willing to use a move for. If it's too high, than we are not using all our moves, and if it's too low, then we are wasting moves.

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

      For example, if we take a = 5 what value of (bi) I should take and why because it is always decreasing and there is no minimum ? What is the basis of minimum ? Is it value of K?

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

        The value of $$$b_i$$$ depends on $$$a_i$$$ for other types also. Try the sample test case. For each type of project, find the score for each value of $$$b_i$$$. Then find the answer for each value of $$$k$$$ from $$$1$$$ to $$$\sum a_i$$$.for each value of k find the minimum increase you got from a project you added. You'll then understand how binary search was used here.

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

Can anyone explain why in div 2 problem c solution after getting i + a[i] , we find modulus of this term? Why is it required even one number is negative it will be on left side and not repeated please if anyone can explain this properly.

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

In Div 2 F, what if there isn't an $$$A$$$ which can make $$$b_i$$$ increase exactly $$$k$$$ times?

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

This was a very nice contest with very nice questions. Here are my solutions.

I have two questions for Monogon

  • The editorial for $$$E$$$ was a little confusing. Am I right in saying that the number of universal identifiers is equal to the number of connected components as each connected component can have exactly 1 universal identifier ?
  • Can you share the process behind how you came up with the Div $$$2$$$ $$$F$$$ ? How you formulated it and arrived at the quality function ? It was quite nice.
»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Great Problems Well done Monogon Please write more problems on dsa you are a great setter!

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

div1A's test data is weak ,my O(n^2) program solves the problem.

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

How can we apply DP on Problem B?