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

Автор Prakul_Agrawal, 6 недель назад, По-английски

2217A - The Equalizer

Idea: shakr
Problem Setting: AS23, shakr

Hint 1
Hint 2
Hint 3
Solution
C++ Code
Python Code

2217B - Flip the Bit (Easy Version)

Idea: SilverTongue1729
Problem Setting: penguinnoob, sumit_kk10, Prakul_Agrawal

Hint 1
Hint 2
Hint 3
Solution
C++ Code

2217C - Grid Covering

Idea: biswas
Problem Setting: biswas, SavageFighter001, shakr

Hint 1
Hint 2
Solution
C++ Code

2217D - Flip the Bit (Hard Version)

Idea: Prakul_Agrawal
Problem Setting: h2rsh, Prakul_Agrawal

Hint 1
Hint 2
Hint 3
Hint 4
Solution
C++ Code

2217E - Definitely Larger

Idea: shiven
Problem Setting: tanaygad, kevaljain

Hint 1
Hint 2
Solution
C++ Code

2217F - Interval Game

Idea: Prakul_Agrawal
Problem Setting: Prakul_Agrawal

Hint 1
Hint 2
Hint 3
Hint 4
Hint 5
Solution
C++ Code

2217G - Down the Pivot

Idea: SilverTongue1729
Problem Setting: Faizal, SilverTongue1729

Hint 1
Hint 2
Hint 3
Hint 4
Hint 5
Solution
C++ Code

2217H - Closer

Idea: shiven
Problem Setting: shiven

Solution
C++ Code
  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

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

D was stupidly hard And C... no comments

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

The worst round possible T-T. I don't like this contest

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

In Problem A, “he chooses some $$$a_i \gt 0$$$ and decrements it by $1$”

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

Guess forces?

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

For E, you can also solve by decreasing $$$i$$$. The idea is equivalent to solving by decreasing $$$p_i$$$

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

Calculate the ratings pls, it's 9 hours since the contest ended!

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

I think that $$$D$$$ and $$$E$$$ are nice, even tho I couldn't solve either, but they were fun to think about. Good job guys. Also, I think that $$$D$$$ and $$$E$$$ would definitely have like $$$\le 50\%$$$ of their solves if there were no cheaters. And $$$F$$$ having $$$120+$$$ trusted solves is crazy. cf contests would still be relatively clean if all these obvious cheaters were removed, hell probably $$$60-70$$$ people in the trusted top $$$100$$$ would get removed. If a few trusted active people could just ban whomever they wanted to, and they really cared about removing all the cheaters, they'd clean the standings up, no doubt. Also, take someone with $$$\le 1400$$$ rating (including unrated people) in the top $$$100$$$. The probability that they are a cheater is much greater than the probability that they are a legit participant, so people should just ban them and then they can appeal, and when the cheaters appeal, their responses will be chat GPT and obvious, so it'd be a lot less work.

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

Hola

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

I have been working on 1700 rated questions recently, but it seems like the last few Div2 contests have all been going against me.

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

make contest unrated plsss

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

many guys solve c,but i did not...the problem like c i usually can`t solve

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

The number of solves on D does not correspond with its difficulty at all

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

G could be solved quite easily using OGF method.

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

    Can you explain the OGF method in detail?

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

      We can see that the operation can be seperated into two parts,one in left son and one in right son.For sons,the operation has just an unchanged endpoint.The maximum of the costs of the two parts is the final answer(or the final answer decreased $$$1$$$ according to the value of root).So we first talk about the operation which starts from root.

      Let we have $$$f_{n,k}$$$ become the number of trees that has $$$n$$$ nodes ans costs $$$k$$$ steps.Then we have transition $$$f_{n,k}=\sum_a\sum_b f_{a,b}(f_{n-1-a,k-b}+f_{n-1-a,k-b-1})$$$.Notice that the transition of the second dimension is convolution.We can see $$$f_{n,*}$$$ as a poly $$$F(n)$$$ of $$$O(n)$$$ nums.Then we have $$$F(n)=(x+1)\sum_a F_a(F_{n-1-a})$$$.And we can indicate that $$$F(n)=C_n(x+1)^n$$$ where $$$C_n$$$ is Catlan number.

      So we can get any $$$f_{n,k}$$$ in $$$O(1)$$$ time.

      And the final answer is $$$\sum_a g(a,m)g(n-a-1,m)-\sum_a g(a,m-2)g(n-a-1,m-2)$$$,where $$$g(n,k)$$$ equals to $$$\sum_{t=0}^k f_{n,t}$$$.And to calculate it we just need to maintain the presum of binoms.

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

unevenforces?

A easy, B easy, C damn hard, D damn hard and so on.

the hardness of B and C were uneven. like 900 rated problem then the next problem is 1500!

Problem C was very AI able. so cheaters used AI, thats why this many AC!

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

In problem C, how we justify that to return again to (1,1) we need complete cycles. It may be possible that to reach again (1,1) we perform k+1 row and k column operations or vice versa.

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

    Yes, you may reach $$$A_{1,1}$$$ without completing a full cycle, i.e., in $$$k+1$$$ row and $$$k$$$ column operations. However, if you continue performing operations after this, you may still visit previously unvisited states.

    Simply reaching $$$A_{1,1}$$$ again is not sufficient. Only when you return to it after completing an equal number of row and column operations will you start repeating the states you have already encountered.

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

How did so many authors make such a bad contest?

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

This contest gave me cyan name.

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

[delete]

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

B was good

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

I am thinking about giving up.

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

For those who solved problem C, how did you come up with the solution? Did you guess it based on some small observations, or did you do a formal proof before claiming the gcd(n, m) <= 2 fact? When I read the official solution, there are some tricky cases that make the observation not trivial to prove. So I'm curious, how did you arrive at the solution? Was it pure mathematical proof, or a lot of guessing?

Here is my thought process during the contest (which turned out to be false):

We know that we must have gcd(N, A) = 1 and gcd(M, B) = 1. I considered blocks of 2N moves. Suppose I start with a down move, and then I perform exactly 2N moves in total. We can observe that I make N right moves and I return to row 0: (0,0) → (0, N*B). If I then perform another 2N moves, I return to row 0 again and make another N right moves: (0,0) → (0, N*B) → (0, 2*N*B). So since the beginning, I've made 2N right moves, and so on. Thus, each time I complete a block of 2N moves, I end up on the same row but shifted to the right by N*B columns. Therefore, to be able to visit all cells on that row, we must have gcd(N*B, M) = 1. This can be generalized to all rows.

During the contest, I wasn't able to prove that my observation was wrong. With a simple example like N=2, M=2, A=1, B=1, it's obvious that it fails. I knew it was false because of the WA, but I couldn't see what in my reasoning made my solution incorrect.

Here I have another question, more general about problem solving: sometimes you have a wrong solution and it can be hard to tell exactly why it's wrong. When that happens, I tend to not move on to another approach until I find out why it's wrong. I tell myself, "Maybe this is the solution, I have to be sure," so I lose time on a hard path that might be misleading. Do you guys, when you find yourselves in this situation, just try other things, or do you continue like me even if it might not be the right way?

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

    I guess it was something called AI

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

    I didn't do the gcd(n,m)<=2 instead I noticed that let's say that we have gcd(n,a)==1 & gcd(n,b)=1, now if you reach a cell where you have been before without completing the whole grid, that would mean that it is not possible, now to find the condition for it, let's say we can just go down, it will take me n steps to get to the initial cell, now if I do the alternating steps then if we get j*n*b mod m==0, where j is any whole number, so we get that after doing j*n amount of alternating steps, we reach the same point we started at, so if before reaching this we already covered the whole grid, then the answer is YES, otherwise NO.

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

      In my thought process during the contest (which I described above), I had a similar idea: to check whether all cells in a row are visited, I looked at gcd(N*B, M)=1. I ended up with this reasoning, but it turned out to be wrong. How do you actually check whether all cells are visited, knowing that if j*N*B mod M == 0 you'll be stuck in a cycle?

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

    Given that $$$\gcd(N, A) = 1$$$ and $$$\gcd(M, B) = 1$$$, the problem is equivalent to an instance with $$$A = B = 1$$$ by permuting rows and columns in the order that they are visited. Say you "mark" a square $$$x$$$ if you move down into square $$$x$$$. Then, $$$\gcd(N, M) = 1$$$ means that you mark every single square in row 0. However, you actually visit two squares for every marked square, and additionally these squares are adjacent. Therefore, you only need to mark every other square to fully cover the row. This motivates $$$\gcd(N, M) \leq 2$$$.

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

      Wow, simplifying the problem to make it with A=B=1 is genius!I see it now. Here it works because when you return to row 0 you go N times to the right since the last time you were at row 0.

      When you consider the case with gcd(N,M)=1 you explore all the squares in the row, but when you have gcd(N,M)=2 you explore all the 0,2,4,2i,... cells in row 0. Here, like you said, since the first square in each row you enter you will enter the right adjacent square, then you will also explore all the 1,3,5,...2i+1,... squares.

      To prove it you need the following fact: Consider you are on a line, with squares from 0 to M-1. When you begin at 0 and add some X, you will be at k*X mod M (where k is a natural number). If you have gcd(X,M) = d, then if you add X to your position, you will visit all squares from 0 to all multiples of d. It's at the end a very interesting problem!

      Did you notice this fact (or know it) during the contest or just guess it?

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

        I’d say it came to mind right after $$$\gcd(N, A) = \gcd(M, B) = 1$$$, since this implies every consecutive N vertical moves is a permutation on the rows (same for M horizontal moves and columns)

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

    Assuming that the gcd(n,a) = gcd(m,b) = 1.

    You can easily show that after m steps to the right you will be back at column 1, and after n steps down you will reach column 1. The first time you get back to your starting square will be after you take lcm(n,m) steps down and lcm(n,m) steps to the right. This will happen after 2 * lcm(n,m) steps, (because the steps alternate, i.e. you take one step to the right every two steps)

    So at most you will visit 2 * lcm(n,m) squares. For this to cover the whole grid, you need:

    • 2 * lcm(n,m) >= n * m
    • 2 * n * m / gcd(n,m) >= n * m
    • 2 / gcd(n,m) >= 1
    • 2 >= gcd(n,m)

    But since these two are equivalent anyways, you can just check that 2 * lcm(n,m) >= n * m and that should be enough

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

    My friend just noticed it while looking through the tests idk

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

why in F problem the answer need to multiply with $$$2^{popcount(X)}$$$?

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

why i cant inspect others code for this contest or is it for all problems?

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

The tutorial for C only proves that (0, 0) will be visited with the exact same next move after 2*lcm(n, m) moves, does it necessary means the same holds for all other tiles (it's the minimum number of moves)? Also, it assumes cell is reached after full cycles, but there might be different situations, return to cell might happen with last step being to right or down (2nd time repetition)?

For gcd=1 case, I'm not 100% convinced this is true: "By symmetry, every tile is visited exactly twice (once in each direction).", why is it like that (symmetry argument), perhaps some tiles are visited more often (3 times, not 2 times) than others?

Also for gcd=2 case, "In State 1 (ready to move Right)", "In State 2 (ready to move Down)" means the proof is for case when first move is Right, I suppose the proof for 1st move being Down is similar.

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

An interesting topo sort based approach for E greedily assigning values in reverse order to the lowest current index possible 370418252

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

problem E has a super simple solution. Go through the positions from right to left:

  • If $$$d_i = 0$$$, set $$$q_i = n-i$$$
  • If $$$d_i$$$ is bigger than the number of $$$j$$$ s.t. $$$p_j \gt p_i$$$, it's impossible
  • Otherwise, sort such positions by $$$q_j$$$, set $$$q_i$$$ to the $$$d_i$$$-th biggest $$$q_j$$$ and increment the $$$d_i$$$ biggest $$$q_j$$$

Naively this is $$$n^2 \log n$$$ but you can remove the log using nth_element

370481649

EDIT: The naive solution also gets AC lmao 370482111

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

Problem D explanation:

  1. convert the initial array as follows: a[i] = (a[i] != specialValues). so 1 means it have to be flipped and 0 means it's already equal to the special values
  2. Now the problem is what's the minimum number of operation(range xor/flip) required to achieve the sequence a from an array where all elements are 0(not flipped any elements yet).
  3. suppose doing operations on some range {(p1, p2), (p3, p4), (p5, p6)} can achieve the required sequence a
  4. From the "Difference Array" concept, we can mark these ranges as {(p1, p2+1), (p3, p4+1), (p5, p6+1)} We can reconstruct our sequence by doing prefix XOR on this difference array.
  5. See, now the pairing is not fixed. I mean, we can pair the landmarks any way and still we can get our sequence by prefix xor e.g: doing operations like this: {(p1, p5), (p2+1, p3), (p4+1, p6+1)} also give the same sequence a
  6. our problem has a condition that each pair must have atleast one special index. so we can pair these points in such a way that each pair met the condition
  7. If we have n points, we required atleast n/2 pairing/operations to achieve our sequence
  8. what can be maximum?

    i. it depends on the number of points have in each region divided by the special indices Because, we can't pair using two points from the same region since it doesn't contain special index.

    ii. suppose the points are divided as: p1 | p2+1, p3, p4+1, p5 | p6+1 | here, second region has 4 points and we have only two points outside this.

    iii. In this types cases where a region may have > n/2 points, there will be some points left which can't be paired. those remaining points each will have to resolved individually by allocating a new point to them.

    iv. here, the total landmarks as well as the remaining points must be even.

    v. suppose, in the above scenario, remaining points are p4 and p5. we have to select a point k such that there is atleast one special index between (k, p4+1) and (k, p5). so pairing in such a way ultimately resolve the issue. And it's guaranteed that resolving in this way will be always possible.

    vi. so, in this scenario, required operation is 4(max point count of any region):(p1,p2+1),(p3,p6+1),(k,p4+1),(k,p5)

  9. Hence the ans = max(n/2, mxPointCount)

Here is full code with comment: https://mirror.codeforces.com/contest/2217/submission/370576348

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

Alternative proof for problem C that there's no such $$$x = k_1 - k_2$$$, that

$$$ \begin{cases} x \equiv 0 \pmod n \\ x \equiv 1 \pmod m \\ \end{cases} $$$

Let's write down numbers $$$0, n, 2n, \ldots \pmod m$$$. They all have a remainder 0 modulo $$$n$$$.

We need to find such $$$k \cdot n \equiv 1 \pmod m$$$. Here, we can apply $$$\gcd$$$ rule, which says that if we have numbers $$$a$$$ and $$$b$$$, $$$a \bmod b$$$ is divisible by $$$\gcd(a, b)$$$. (If you wish I can prove it too).

But since $$$\gcd(n, m) = 2$$$, all numbers $$$0, n, 2n, \ldots \pmod m$$$ are divisible by 2, so there's no $$$1$$$ in that series. Thus, no such $$$x$$$ exist.

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

Why do we start from 0 in problem B's code?

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

Love E

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

can anyone simplify the condition for B to work, how does padding at the ends simplify the problem here. Thanks

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

What kind of problems should I solve to be able to easily solve problem like C?

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

2600 for G???? That doesn't make sense...

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

How did this many people solve C man something is definetly fishy