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

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

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
  • Проголосовать: не нравится

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

Thank you for great round and fast editorial

»
5 лет назад, # |
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.

»
5 лет назад, # |
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 :) :)

»
5 лет назад, # |
  Проголосовать: нравится +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.

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

    It might be a good idea to limit the number of participants so that codeforces would work well (around 10000). Div 2 people will participate more rarely on average, say once a week instead of twice, but without long queues. The only effect on div 1 is reducing queues.

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

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

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

what will be the quadratic formula for B?

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

    For a given n:

    t = floor( ( -1 + sqrt( 1 + 24*n ) ) / 6 )

    then the tallest tower that can be built from n is : 2 + ( (t-1)*(3t+4) )/2

    keep subtracting this from n and recalculating 't' and tallest tower as long as n > 1

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

      Why did you not take t = floor( ( -1 — sqrt( 1 + 24*n ) ) / 6 )?

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

        t cannot be negative, t represents the index of the sequence: 2 7 15 26 ... and floor to make sure that index doesn't point to a term > n

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

      How did you compe up with this formula?

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

        More practical method is to use the recurrence from the problem and let https://www.wolframalpha.com/ solve it for you so you get n(h) (number of blocks needed to build pyramid of height h). Then you can also let it solve for the inverse and floor it to get the maximum height h' you can build using n blocks. This works because the function is increasing. Then you just do n -= n(h'). And you repeat this while keeping count.

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

        If you look closely you can observe that in every structure there are complete triangles on every level except for surface. The no. of triangles are 1,1+2,1+2+3,1+2+3+4,....so on. so for nth structure there will be n(n+1)/2 no. of triangles, hence required card should be 3*n*(n+1)/2. But we know that we have to subtract base level no. of cards, hence final formula will be (3*n*(n+1)/2)-n. after rearranging this we get (3n^2+n)/2. Now you can reverse calculate highest tower n by making it equal to given number and solving the quadratic eqn.

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

      But this show TLE on 10^9 test case 4. I don't understand why this is happening.

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

        you need to change 24*n to 24LL*n.

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

          Can you please elaborate upon how this works, what is the error in earlier choice It would be a great help

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

            Long in cpp has maximum value (2^31-1), so it's bad when n = 1e9 and 24*n is 1e10, it is leading to overflow. You should use long long for variables where you're not sure whether you might overflow using int/long.

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

    a much easier to understand formula is (trng(n)*3)-n where trng is the nth triangular number. Notice that there are 1, 3, 6, 10... triangles in the structure and each triangle requires 3 cards. Then we subtract n cards, as we do not need cards at the bottom.

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

    i know a better approach to find the formula

    for a height h there will be 2*h no. of cards at the base there will be total of (h-1)*((h-1)+1)/2 no. of triangles now just run a loop till n<2 https://codeforces.me/contest/1345/submission/79162987 link to my submission

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

loosed +160 delta

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

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

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

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

  • »
    »
    5 лет назад, # ^ |
      Проголосовать: нравится +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..

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

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

»
5 лет назад, # |
  Проголосовать: нравится +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!

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

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

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

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

  • »
    »
    5 лет назад, # ^ |
      Проголосовать: нравится +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).

    • »
      »
      »
      5 лет назад, # ^ |
        Проголосовать: нравится 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.

      • »
        »
        »
        »
        5 лет назад, # ^ |
        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.

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

        yes

    • »
      »
      »
      5 лет назад, # ^ |
      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)$$$.

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

        if n = 5, in your case 2, does not room 0 goes to room 0 + a[0] % 5 = room 0 ? Why does guest in room 0 goes to room 5?

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

          I think you are missing that the mod operation is on the subscript and not on $$$a_{i}$$$

          if $$$n = 5$$$, then guest $$$0$$$ would go to

          $$$0 + a_{0 mod 5}$$$ $$$=$$$ $$$0 + a_{0}$$$ $$$=$$$ $$$0 + 5 = 5$$$

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

        A little typo in this line $$$a_{i} + i (5 + 1 \times 5 = 5)$$$.

        It should be $$$a_{i} + i (5 + 1 \times 5 = 10)$$$.

    • »
      »
      »
      5 лет назад, # ^ |
        Проголосовать: нравится 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

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

        you have to take into account the mod of negative number with n

        a[i] = a[i] + i; a[i] = (a[i])%n; if(a[i]<0){a[i] = a[i] + n;}

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

          still wrong

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

            int main() { int t;cin>>t;

            while(t--)
            {
            
            long long int n;
            
            cin>>n;
            
            long long int a[n],i;
            
            unordered_set<long long int>s;
            
            for(i=0;i<n;i=i+1)
            
            {cin>>a[i];a[i] = i + a[i];}
            
            for(i=0;i<n;i=i+1)
            {
            
                a[i] = a[i]%n;
            
                if(a[i]<0){a[i]=a[i]+n;}
            
                s.insert(a[i]);
            
            }
                if(s.size()==n){cout<<"YES"<<endl;}
            
                else{cout<<"NO"<<endl;}
            
            }

            } *****hope this helps

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

              if(a[i]<0){a[i]=a[i]+n;} can you explain this step plz

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

                modulus of a negative number can be written as a %m = (a + m)%m example: -1 % 20 == (-1 + 20)%20; =19;

  • »
    »
    5 лет назад, # ^ |
      Проголосовать: нравится 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..

  • »
    »
    4 года назад, # ^ |
    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$$$

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

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

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

Can someone explain C again?

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

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

    The shuffle is k + (a_k mod n). So, for example, if a_1 = 12 for n = 7, room 1 will go to room 1 + (12 mod 7) which is room 6. Room 8 will also go to 8 + (a_1 mod 7) since 8 = 1 mod 7, so room 8 will go to room 8 + (12 mod 7) which is room 13. In general, room 1 + kn will go to room 1 + kn + (a_1 mod 7) = 1 + kn + 5 = 6 + kn. Hope this was helpful.

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

      Oops, I made a slight error. It is actually k + a_(k mod n). So in the example I gave where a_1 = 12 and n = 7, room 1 goes to room 1 + a_(1 mod 7) = 1 + a_1 = 13, and room 8 goes to room 8 + a_(8 mod 7) = 8 + a_1 = 20, and in general room 1 + kn goes to room 1 + kn + a_((1 + kn) mod n) = kn + 1 + a_1 = kn + 13.

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

    Yes, but notice that he is taking $$$0 \leq i < n$$$ so we have $$$i$$$ $$$mod$$$ $$$n = i$$$. The same goes for $$$j$$$.

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

      I know that, but that proof from the tutorial: i+ai≡j+aj(modn), why everything mod n ?

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

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

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

    Same with me. Solved A,B,C within 20 minutes. I had a significant increase in rating even if I hadn't solved any other problem.

»
5 лет назад, # |
  Проголосовать: нравится +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.

»
5 лет назад, # |
  Проголосовать: нравится 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.

  • »
    »
    5 лет назад, # ^ |
      Проголосовать: нравится +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.

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

      why we can not fill all cell with south pole question D/B Div2/Div1

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

        I think you replied to the wrong comment. But to answer your question:

        Your solution has to have the property that all white squares are unreachable. If you put south pole magnets everywhere, then every square will be reachable by a north pole magnet, which is bad.

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

          thanks for your reply i got my mistake . yes i replied to wrong comment because before this i asked two times and no one replied so i find random people who was online ,and u was the first one

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

      Thank you so much. That was a great explanation.

»
5 лет назад, # |
  Проголосовать: нравится 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?

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

    Read the problem statement carefully. There are infinite rooms.

    • »
      »
      »
      5 лет назад, # ^ |
        Проголосовать: нравится 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

      • »
        »
        »
        »
        5 лет назад, # ^ |
          Проголосовать: нравится 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

»
5 лет назад, # |
  Проголосовать: нравится 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

»
5 лет назад, # |
  Проголосовать: нравится +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

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

    Suppose I have a graph with two nodes and an edge $$$2\to 1$$$. Node $$$2$$$ has indegree $$$0$$$, yet the statement $$$\exists x_1,\forall x_2, x_2 < x_1$$$ is false.

»
5 лет назад, # |
  Проголосовать: нравится +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.

»
5 лет назад, # |
  Проголосовать: нравится +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???

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

    The problem is that, x3 < x2 Now you have fixed x2, (As There exists x2 comes first in order) , so not all x3 holds x3 < x2.

    A requirement for universality is that the variable is only comparable with larger-indexed variables. It is mentioned in the 2nd paragraph of editorial.

»
5 лет назад, # |
  Проголосовать: нравится 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.

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

    The requirement for a variable x(i) to be universal is that, In the directed acyclic graph, No node x(j) with j < i can reach x(i) and x(i) also cant reach such x(j). In other words, all nodes reachable from x(i) and reachable to x(i) should have higher labels.

    To check that, we do DP and find minimum below and minimum above in reversed graph.

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

      Can you explain this testcase:

      5 4

      1 2

      1 3

      5 1

      4 1

      The correct answer is: AEEEE.

      I can make x2 and x3 anything and set x1 as min(x2,x3), I can set x4 and x5 according to x1 , So won't the answer be 2 EAAEE. What am I missing here?

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

        Problem Statement says :

        Note that the order the variables appear in the statement is fixed. For example, if f(x1,x2):=(x1<x2) then you are not allowed to make x2 appear first and use the statement ∀x2,∃x1,x1<x2. If you assign Q1=∃ and Q2=∀, it will only be interpreted as ∃x1,∀x2,x1<x2.

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

      Can I rephrase it as

      The element with the smallest index in every chain of the poset gets 'A' rest all 'E'?

»
5 лет назад, # |
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.

»
5 лет назад, # |
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

  • »
    »
    5 лет назад, # ^ |
    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).

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

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

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

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

»
5 лет назад, # |
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]?

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

    actually k is included in R.because we have infinite room.once we reorganize the position,we are able to let the k pos guest move to k+a[k mod n] position

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

      o,It's my fault. But I cannot understand this code

      why need we mod n in (i + a[i] % n + n) % n; and why i in [0, n — 1]

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

        Let's divide the R into segments,each segment contain n elements;

        We find that for each ith element,it transforms to the (i + a[i] % n + n) % n th in one segment;

        if every i in [0,n-1] obey the rule -- each transformation make unique pos in those segment,then for each new position of element,it won't be the same place(not violate the rule the problem statement show)

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

          as for i in [0,n-1],we can make sure that the other segment(such as [n,2n-1])is also follow the rule

          actually,the range of i we choose could be the set which contain n successive integer

»
5 лет назад, # |
  Проголосовать: нравится 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.

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

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

    • »
      »
      »
      5 лет назад, # ^ |
        Проголосовать: нравится 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?

      • »
        »
        »
        »
        5 лет назад, # ^ |
          Проголосовать: нравится 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.

        • »
          »
          »
          »
          »
          5 лет назад, # ^ |
            Проголосовать: нравится 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.

          • »
            »
            »
            »
            »
            »
            5 лет назад, # ^ |
              Проголосовать: нравится 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

            • »
              »
              »
              »
              »
              »
              »
              5 лет назад, # ^ |
                Проголосовать: нравится 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!

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

    Like this? 79238791.

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

»
5 лет назад, # |
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

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

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

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

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

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

    yes i have the same question

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

    We can put a south pole magnet in any black cell. Out of the white cells, we can only put south pole magnets at intersections of completely white rows with completely white columns. If a row (or column) contains at least one black cell and we put a south pole magnet in one of its white cells, then the south pole magnet will be able to pull a north pole magnet from the black cell to the white area at some point, since each black cell must be reachable by a north pole magnet by the problem requirement. While all white cells must be unreachable by north pole magnets in any possible sequence of moves.

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

      Nicely explained!!

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

      Why in the first place do we need to place north poles in the grid? Or did I missed something? Can't the minimum no. of north poles be 0 in all cases except -1?

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

        Because every black cell must be reachable by a north pole magnet, it is rule #2 from the problem statement. So we need at least one north pole in each black connected component (area composed of adjacent black cells). The only case when 0 north pole magnets is the right solution is when the entire grid is white.

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

          Thanx for responding. It was written that it is possible for the N pole to reach the black cell and not must, and that's why I had such doubt.

          Don't you think the problem statement was a bit confusing in the way that it used possible instead of must there?

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

            Such a shit statement. I fucking urge contest writers to learn some basic English before writing problems. Time wasters like this really annoys me.

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

    Because North pole can't occupy white cell, and North pole can reach the cell which be occupied by South pole if they are in same Column or Row.

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

    Consider this situation.

    Spoiler

    If you fill all cells with South pole and put a North pole in the centre cell, you cannot satisfy rule 3.

    Actually pretest 2 is a good example and you should check it out.

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

    because a sequence of operations must exist for every black cell such that it ends up being occupied by a north magnet

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

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

»
5 лет назад, # |
  Проголосовать: нравится 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."

  • »
    »
    5 лет назад, # ^ |
      Проголосовать: нравится +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

»
5 лет назад, # |
  Проголосовать: нравится 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

»
5 лет назад, # |
  Проголосовать: нравится +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.

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

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

79245621

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

    I think you have not considered the case where some rows and columns might be empty

    Test case
»
5 лет назад, # |
  Проголосовать: нравится +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

»
5 лет назад, # |
  Проголосовать: нравится +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?

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

    guest 1: $$$1 + a_{1 \bmod 2} = 1 + a_1 = 1 + 1 = 2$$$

    guest 2: $$$2 + a_{2 \bmod 2} = 2 + a_0 = 2 + 0 = 2$$$

»
5 лет назад, # |
  Проголосовать: нравится 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!

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

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

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

    Amazing buddy it helped so much to solve this problem :) Keep going on like this for every difficult problem . thanks for this

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

Why is this MLE? Monogon

Isin't the answer same as the editorial : 79185068

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

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

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

Can someone please explain div 2 problem F?

»
5 лет назад, # |
  Проголосовать: нравится 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.

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

    Change return -1 to return 0. Exit code is whatever the main function returns. If it does not return 0, then it becomes a runtime error.

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

      Omg, thank you! I don't think I would've figured that out, and the internet wasn't being much help.

»
5 лет назад, # |
  Проголосовать: нравится 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?

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

    You are forgetting that there has to be at least one south magnet in every row and every column. In your solution, there is no south magnet in neither row 1 nor column 1. Also, both of these have two segments of black cells, so answer should be -1.

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

      Yeah, thanks. I don't know why I was forgetting this condition for this test case.

»
5 лет назад, # |
  Проголосовать: нравится 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

»
5 лет назад, # |
  Проголосовать: нравится 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?

  • »
    »
    5 лет назад, # ^ |
      Проголосовать: нравится +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.

    • »
      »
      »
      5 лет назад, # ^ |
        Проголосовать: нравится 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?

      • »
        »
        »
        »
        5 лет назад, # ^ |
        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.

»
5 лет назад, # |
  Проголосовать: нравится 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.

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

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

»
5 лет назад, # |
  Проголосовать: нравится 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.
»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

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

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

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

How can we apply DP on Problem B?