innocentkitten's blog

By innocentkitten, 6 weeks ago, In English

Hope you enjoyed the problems!

UPD 1: Added implementations!

UPD 2: It seems my wording for the solution to C is not the best, and it is causing some confusion. I've updated it to be better!

UPD 3: Implementation links didn't work for some reason, so I've just added the code directly.

2055A - Two Frogs

Hint 1
Solution
Implementation

2055B - Crafting

Hint 1
Solution
Implementation

2055C - The Trail

Hint 1
Hint 2
Hint 3
Solution
Implementation

2055D - Scarecrow

Hint 1
Hint 2
Hint 3
Hint 4
Hint 5
Solution
Implementation

2055E - Haystacks

Hint 1
Hint 2
Hint 3
Hint 4
Solution
Implementation

2055F - Cosmic Divide

Hint 1
Hint 2
Hint 3
Hint 4
Hint 5
Solution
Implementation
  • Vote: I like it
  • +142
  • Vote: I do not like it

»
6 weeks ago, # |
  Vote: I like it +23 Vote: I do not like it

fast editorial...orz

»
6 weeks ago, # |
  Vote: I like it +12 Vote: I do not like it

woah that was fast! we've been getting lots of quick editorials lately, nice!

»
6 weeks ago, # |
  Vote: I like it -29 Vote: I do not like it

c was cool

»
6 weeks ago, # |
  Vote: I like it -46 Vote: I do not like it

tell me I'm not the one who use lazy segtree on B

»
6 weeks ago, # |
  Vote: I like it +3 Vote: I do not like it

oh wow, thank you for fast editorial

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

What in the Itachi Crow Montage D problem :}

»
6 weeks ago, # |
  Vote: I like it +3 Vote: I do not like it

I spent lot of time to figure out C, but then was about to give up without any idea, but then I tried to make a submission by making sum of rows and column Zero, and it worked .. I am not proud. But I hope to get some idea from the editorial.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Oh yeah, I was also thinking along the same lines. But without any proof I did not try it further.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Why zero? I got the case when n=m (a square) but my code didn't work for rectangles, perhaps because I assumed x. Does x=0 work throughout?

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    ok I think Sum = 0 works because n*S = m*S ... does that mean when n!=m ... there is no other possible value of S .. actually I was trying to find that value but didn't get any ideas

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

I never thought that Problem D is a Greedy!

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Can someone please tell me why my submission 300745220 for Problem D is failing?

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +14 Vote: I do not like it

    The logic seems correct, but the error may be with the way you print the answer. Your val is long double, so when it becomes large enough, it prints in scientific notation, e.g. 4e+08 instead of 400000000

    Converting to long long should fix that: cout << 2 * (ll)val << endl;

    And generally, as a rule of thumb, if the answer to the problem is an integer, but your variable is a floating point, better always cast it to the int before printing, just in case :)

»
6 weeks ago, # |
  Vote: I like it +1 Vote: I do not like it

Use binary search, problem C is possible. Really inspiring problem C, I hardly solved it in 90mins.

I feel upset that I didn't solve it like editorials. I should practice more.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    its completely normal to have a solution that isnt like the editorials.

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I feel my solution was completely complex, did anyone do like this?300738374

      • »
        »
        »
        »
        6 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Could you explain what are you binary searching on?

        • »
          »
          »
          »
          »
          6 weeks ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          We choose any $$$x$$$ to fill $$$(1, \, 1)$$$, then the next cell can be calculate. After $$$n + m - 2$$$ operations, we still remain the last cell of $$$(n, \, m)$$$. Any number $$$a$$$ we choose may not satisfy, the sum of cols and the sum of rows have difference. The difference can be positive of negative(decided by the last operation you do on the row or col). We assume that we operate on the last row, and donate $$$\Delta x = sum_{row} - sum_{col}$$$. If $$$\Delta x < 0$$$, we need to enlarge the last number to ensure it can be an equation. So try to enlarge $$$x$$$ and try to fill the cells again.

          • »
            »
            »
            »
            »
            »
            6 weeks ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            Hi can you explain why S = 0 works for the case when n == m as then we can have a solution where S can be anything?

            • »
              »
              »
              »
              »
              »
              »
              6 weeks ago, # ^ |
                Vote: I like it 0 Vote: I do not like it

              Why won't it work? , like clearly S*n = S*m , as you claim(n == m) , they cancel out leaving S = S , which is always true , as it turns out S can be set to any value so obviously S = 0 will work as well....But since when n != m , S needs to be set to zero , then its beneficial for us to always choose s = 0 so that we can do it in a single algo....

              • »
                »
                »
                »
                »
                »
                »
                »
                6 weeks ago, # ^ |
                  Vote: I like it 0 Vote: I do not like it

                got it thanks

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  5 weeks ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  What he said is not correct, how do you even get it? S*n = S*m and canceling doesn't mean anything, you still don't know the value of S.

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  5 weeks ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  Hey S*n = S*n means S will satisfy for every value if you look at this equation only so S = 0 will be one of the solution here in this case you can have any sollution , you can compute S to any random number also in this case and you will get a solution for all values

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  5 weeks ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  In the question some part of the matrix are fixed numbers, you have to prove the S = 0 works based on the given matrix, not just looking at S*n = S*n. It only means you can find a n*n matrix with row and column of sum S and S can be any value but it has nothing to do with the question.

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  5 weeks ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  Again if S = 0 then we can have solve this problem as defined in a approach and we can have one equation and one variable for missing number (0) so we will definitely have a solution and then Sum of all rows and columns will be same so all constraints are satisfied

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  5 weeks ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  Yes, that's what I am talking about. You have to prove it with the approach to say that it works for any integer not because just a S*n = S*n.

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  5 weeks ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  See what i initially claimed was correct , in fact it is correct , what S*n = S*m means is , we are trying to find such a S(sum of all rows/columns) which we can have in order to satisfy the properties that the question mentions. That's it!! , since S = 0 satisfies the equation whatsoever , we can always have S = 0 as a solution (as 0 = 0) will satisfy.

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  5 weeks ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  I don't get what Super_D_Man is exactly trying to say here , for a square matrix (n = m) so , we get S*n = S*n , which should be in itself a proof that any value of S will satisfy the equation S = S (as n's cancel out) , so for a square matrix , choosing any S should do our job , if he is trying to ask us for a proof for how can we always get that desired S by setting some values in the place of the hidden ones , then its simple , since the string only contains R's and D's , we know that it has to go down EXACTLY n times and go to the right exactly M times in order to reach (n , m) , so eventually each row , and each column will always have at least one variable which could be used to set the value of S in that row/column.

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  5 weeks ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  that's the same thing i thought

          • »
            »
            »
            »
            »
            »
            6 weeks ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            Hey. I am not sure I understand your idea of binary searching over sum value but in your code , you will never have more than one iteration as sum=0 in first iteration itself which will satisfy required conditions.

            • »
              »
              »
              »
              »
              »
              »
              6 weeks ago, # ^ |
                Vote: I like it 0 Vote: I do not like it

              Oh, it could be a coincidence, after all, I didn't even think about that aspect of $$$S = 0$$$ when I was working on the problem.

          • »
            »
            »
            »
            »
            »
            5 weeks ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            Actually, if we choose $$$x$$$ to fill $$$(1,1)$$$, and donate $$$y = sum_{row} - sum_{col}$$$, we can notice that they have a linear relationship, which means $$$y = k \times x + b$$$. So, we can successively let $$$x = 0,1$$$ and fill the cells, then calculate the value of $$$k,b$$$. After that, let $$$x = -\frac{k}{b}$$$, and fill the cells again.

            My English is quite poor. If you can't understand me, you may check my submission. Some of the implementations in my code differ from the above process to some extent.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I tried to use binary search for C as well here: https://codeforces.me/contest/2055/submission/300745300

    But I still don't know why it doesn't pass, because from my analysis, my program would eventually search the case where $$$S=0$$$.

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it +1 Vote: I do not like it

      The difference between the last row and last col can be positive or negative. You should check if it is positive, then let $$$r = mid - 1$$$, or it will get wrong.

      • »
        »
        »
        »
        6 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        That's what I tried to do. In my code, one of the sums (either row or col) will be equal to $$$S$$$, depending on whether the last instruction was D or R, so when I check whether one of the sums is larger than $$$S$$$, I'm essentially checking whether the difference is positive. I must be missing something here I guess but I still can't really see where in my program is wrong.

        • »
          »
          »
          »
          »
          6 weeks ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          It makes sense. What would happen if you break when the difference equals 0?

          • »
            »
            »
            »
            »
            »
            6 weeks ago, # ^ |
            Rev. 2   Vote: I like it 0 Vote: I do not like it

            why should S be 0 ?

            • »
              »
              »
              »
              »
              »
              »
              6 weeks ago, # ^ |
                Vote: I like it 0 Vote: I do not like it

              The editorials explaiined well. S equals 0 means the matrix gets balanced.

              • »
                »
                »
                »
                »
                »
                »
                »
                6 weeks ago, # ^ |
                  Vote: I like it 0 Vote: I do not like it

                It does explain that $$$S=0$$$ will be the only solution when $$$n \neq m$$$, but it does not prove that a solution always exists when $$$S=0$$$. I'm still wondering about that.

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  6 weeks ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  This kind of question should be more about math. But since the question says that there is a guaranteed solution, you must just find the necessary conditions while working on the problem. I wouldn't be too good at adding a specific proof, but this must be far more difficult than the C and D problems.

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  5 weeks ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  i guess solution always exist because when we solving it we have one variable and one equation so the solution would always exist for each values whether it is stated gurated solution or not

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  5 weeks ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  Maybe the rank of the matrix?

»
6 weeks ago, # |
  Vote: I like it +7 Vote: I do not like it

C was, brutal not gonna lie!

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

    agreed, i had a similar approach to the editorial but i got overwhelmed with the 120 lines of code that i wrote and couldn't debug it in the last 10 mins.

    still, getting this close to solving C being rated 800 feels nice!

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

That's literally what I was trying to do for B and it didn't pass :-| My approach was to create a new array c that's a — b. If there are more than 1 negatives in c (we need to make more than 2 materials) the answer is NO.

Otherwise take the minimum positive in c and check whether it's large enough to turn the negative into 0.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    your approach is correct though, i had the exact same approach and it passed. could you share your code?

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      https://codeforces.me/contest/2055/submission/300708247

      Probably missed something important, will check it out again tomorrow. Thanks for confirming the approach is correct though, I was so confused. lol

      • »
        »
        »
        »
        6 weeks ago, # ^ |
        Rev. 2   Vote: I like it 0 Vote: I do not like it

        there's an edge case missing in your code, you didn't consider the possibility that all the numbers in the array c could be positive.

        when the code runs for such an array c, the variable negative_count equals zero and not 1, and thus your function returns false.

        just change the statement if (negative_count != 1) to if (negative_count > 1) and it'd work.

      • »
        »
        »
        »
        6 weeks ago, # ^ |
        Rev. 2   Vote: I like it 0 Vote: I do not like it

        In addition to what was written above, seems like you're not checking indexes, where a[i] == a[b], and therefore your min_positive is not equal to zero, when it should be

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Damn! Only solved A and B, and was stopped by C lol. Couldn't figure it out for the life of me.

»
6 weeks ago, # |
Rev. 2   Vote: I like it +17 Vote: I do not like it

even tho i didnt do well this has to be the highest quality div 2 in a very long time

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    personally i didn't get to d and onward in time but i'd say the difficulty had a very sudden jump on c,yet the solution to it is very basic it's weird

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I didnt think I could solve D during the contest is D hard for average pupil.I think C was easy for div2c (SO MANY PEOPLE USED GPT UNFORTUNATELY

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    but the balancing was horrendus ,no one ,i mean no one solve E or F

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

E and F so hard.

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

man if i didnt get WA due to using int not ll I would rank 1000 places higher

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it -34 Vote: I do not like it

    made the exact same error, i used claude to fix it

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Aren't there any code that I can read so I can understand better??

»
6 weeks ago, # |
  Vote: I like it +8 Vote: I do not like it

questions were good ngl , although i dont know how to even start D

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Problem C is really amazing.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I can't unserstand why shoudl S be equal to 0 ??

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Because the sum of all rows shoule be equal to the sum of all columns (Both are equal to the sum of all elements), the equation S*rows = S*cols should held. However, the only possible solution is S = 0 when rows != cols. I hope it can help you.

      • »
        »
        »
        »
        6 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        what if rows == cols then how can we gurantee that S = 0 will also be the solution ?

        • »
          »
          »
          »
          »
          6 weeks ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          In this case I think We might find other S that will also be the solution. But S=0 will still be a valid solution

          • »
            »
            »
            »
            »
            »
            6 weeks ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            oh yeah i got it because S = 0 will be one of the solution but whether that solution will match the sum magic criteria ? how can we prove that ?

            • »
              »
              »
              »
              »
              »
              »
              6 weeks ago, # ^ |
                Vote: I like it 0 Vote: I do not like it

              thank i got it now because then we have S = sum(of column) and we will have only one equation and and one variable so in each case some solution will exist for every value

              thanks again

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Can someone point out the mistake in my submission for D 300739742. Looking at the editorial feels like my approach is similiar.

»
6 weeks ago, # |
  Vote: I like it -32 Vote: I do not like it

why this failing for c

// this is code
void solve(){
    ll n,m;cin>>n;cin>>m;
    string s;cin>>s;
    vector<vector<ll> > v(n,vector<ll>(m,-1));
    rep(i,n){
        rep(j,m) cin>>v[i][j];
    }
    
    vector<vector<int> > vis(n,vector<int>(m,1));
    int i1=0;
    int j1=0;
    int x=0;
    vis[i1][j1]=-1;
    while(x<s.length()){
        if (s[x]=='D'){
            i1++;
            vis[i1][j1]=-1;
            x++;
        }
        else{
            j1++;
            vis[i1][j1]=-1;
            x++;
        }

    }

    // rep(i,n){
    //     rep(j,m) cout<<vis[i][j]<<" ";
    //     cout<<el;
    // }
    
    for (int i=0;i<n;i++){
        ll sum=0;
        ll mi=0;
        ll indx=-1;
       
        for (int j=0;j<m;j++){
            
            if (vis[i][j]==-1){
                indx=j;
                mi++;
            }
            else{
                sum=sum+v[i][j];
            }
        }
        if (mi==1){
            
            v[i][indx]=sum*-1;
            vis[i][indx]=1;
        }
    }

    for (int j=0;j<m;j++){
        ll sum=0;
        ll mi=0;
        ll indx=-1;
       
        for (int i=0;i<n;i++){
            
            if (vis[i][j]==-1){
                indx=i;
                mi++;
            }
            else{
                sum=sum+v[i][j];
            }
        }
        if (mi==1){
            
            v[indx][j]=sum*-1;
            vis[indx][j]=1;
        }
    }


    for (int i=0;i<n;i++){
        ll sum=0;
        ll mi=0;
        ll indx=-1;
       
        for (int j=0;j<m;j++){
            
            if (vis[i][j]==-1){
                indx=j;
                mi++;
            }
            else{
                sum=sum+v[i][j];
            }
        }
        if (mi==1){
            
            v[i][indx]=sum*-1;
            vis[i][indx]=1;
        }
    }

    for (int j=0;j<m;j++){
        ll sum=0;
        ll mi=0;
        ll indx=-1;
       
        for (int i=0;i<n;i++){
            
            if (vis[i][j]==-1){
                indx=i;
                mi++;
            }
            else{
                sum=sum+v[i][j];
            }
        }
        if (mi==1){
            
            v[indx][j]=sum*-1;
            vis[indx][j]=1;
        }
    }


    rep(i,n){
        rep(j,m) cout<<v[i][j]<<" ";
        cout<<el;
    }
}
  • »
    »
    6 weeks ago, # ^ |
    Rev. 4   Vote: I like it +25 Vote: I do not like it

    Please use spoiler...

    you can use spoiler like this.

    1) <spoliler>

    2) then three backticks (```)

    3) Then your code.

    4) again three backticks (```)

    5) </ spoiler> ( remove space between / and the spoiler ).

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Can someone please explain me why my submission 300732331 for Problem C is failing? I thought the way i coded that was the same thing that what written on the solution but i guess there's something i don't understand.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    the added value can be long long, which will overflow if you set number type as int, I guess ?

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Yup worked thank you i will stay on long long next time as it cost me a whole problem in a contest ahah

»
6 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

F seems pretty out of place for a Div 2 contest — seems almost at the difficulty level of Div 1E.

The rest of the problems were pretty good. Well done!

»
6 weeks ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

sorry i misread the turorial and made a dum comment

»
6 weeks ago, # |
  Vote: I like it +1 Vote: I do not like it

why in c we have to make sum ==0 of all rows and cols .... why can't we make sum of all rows and col equal max of sum of rows or col or anyother number

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Because s = 0 is the only possible solution for s*rows == s*cols when rows != cols.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    yeah same question, did someone make any other sum apart from zero.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    i got the answer let x be the sum of rows then sum of matrix = nx = mx

»
6 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Considering the difficulty of all the problems, I sincerely wish, if the contest had 2:15 minutes or 2:30 minutes.

I think, I solved D ( passing pretest 1 xD ), right after 5 minutes of contest ending :( .

Code for D, May or May not work.

I don't know, if anyone else solved D, within 10 minutes after the contest.

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

For the problem C, what is the intuition behind trying to make the sums of all rows and columns as 0. In the editorial it is written S.N has to be equal to S.M

But in the problem statement the only requirement is that we need to make sums of all individual rows and column same, am I missing something?

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    so (sum of each row == sum of each column) ..if that sum is 'S', so the total sum of GRID is S * n ... and also S * m .. so they should be equal

    but because n and m can be unequal ... S=0 is a solution to S*n = S*m

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it +1 Vote: I do not like it

      I didn't realise S.n and S.m means the total grid sum. It makes sense. Thank you!

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    sum of all rows=sum of grid and sum of all columns=sum of grid. so sum of all rows x.N=x.M sum of all columns

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Thanks For the Questions and also providing Solutions.. ! A nice event/contest : )

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Solved C before B. I should really think before implementing

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

I got TLE in problem c. If someone finds the problem please let me know. My solution:- https://codeforces.me/contest/2055/submission/300745877

  • »
    »
    6 weeks ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    I am not really sure, but can it be because of using slow input method Scanner or slow output ?

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Damn I misread B and couldn’t solve it but solved C. Now that I see it, I feel so damn dumb. B would be hard ig if in one operation the material increased by (n-1) rather than only 1 and the rest of the procedure remained the same. I wonder how it would play out then.

»
6 weeks ago, # |
  Vote: I like it +2 Vote: I do not like it

feeling happy after climbing mountains of problem C

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Guys, will i reach specialist today?

»
6 weeks ago, # |
  Vote: I like it +17 Vote: I do not like it

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

orz. amazing!!

»
6 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

i submitted 2 correct submissions for problem D(300739717 and 300743089), and 300743089 is just 300739717 with some ints turned into longs. I submitted 300743089 since I was scared that someone might be able to hack it to cause overflow. However, my first submission, 300739717 got skipped because it was almost identical to 300743089, but my second submission 300743089 didn't. Now, I have to incur the extra penalty for the second submission, since i submitted it 8 minutes later than the first. Does codeforces usually do this or should I get the points off of my first submission?

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    Whenever you have multiple submissions that pass pretests, all but the last are skipped. You could have completely rewritten the code without a hint of similarity between the two submissions, and 300739717 would have still been skipped and ignored.

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

for B someone help me in finding the case where this code fails 300733265

  • »
    »
    6 weeks ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    Edit : You can ignore the text below editorial says the same You're taking every negative value into consideration, ig that's the issue

    If there is more than one negative value i,e a[i]-b[i]<0 then the answer will be no as we can never increase more than one value

    Example: a = 1 1 7 6 b = 2 2 3 3

    for i==0

    a = 2 0 6 5 b = 2 2 3 3

    for i==1

    a = 0 2 5 4 b = 2 2 3 3

    and if we keep doing a will perish out after few steps

    and now as we know there can only be one -ve value check if subtracting this negative value from any other element from the vector a doesn't give value less then the corresponding value of vector b.

    ==> if you want to know what will happen in next steps

    3. a = 2 0 3 2 b = 2 2 3 3

    4. a = 0 2 2 1 b = 2 2 3 3

    5.

    for the last index we can't give value from a[0] as subtracting 2 from 0 => -2 which is not possible in this case

    Can check my solution for the same

    If anybody think this is wrong please correct me :)

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      i was just trying to simulate what was asked in question but couldnt do it during the contest because of a small bug. 300753873 this is the correct code of my logic

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Could someone maybe help me with [300707536]? I think I got the logic right but I cant explain why this is failing. Thanks!

(https://codeforces.me/contest/2055/submission/300707536)

»
6 weeks ago, # |
  Vote: I like it +6 Vote: I do not like it

thank you innocentkitten for the wonderful contest and letting catgirl reach master orz

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    did you really become master in 6 months or were you doing cp in the past.

    • »
      »
      »
      5 weeks ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      I did indeed start competitive programming 6 months ago, but I was doing math olympiads before, so that for sure helped ^-^

»
6 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Can someone please explain the maths behind C? My observation:

There exists $$$n + m$$$ variables: $$$n + m − 1$$$ values from cells, and the sum $$$S$$$.

There exists $$$n + m$$$ equations: From each row and each column.

So there can be $$$0, 1$$$ or $$$\infty$$$ solutions. But the editorial choosing sum $$$S$$$ implies there are infinite solutions. What is the proof of this?

Update: Nevermind I understood it.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    so what's your conclusion

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Assume the first sample. Let the unknown numbers be $$$a, b, c, d, e$$$, and the sum be $$$x$$$.

      So the grid is:

      $$$a$$$ $$$2$$$ $$$3$$$

      $$$b$$$ $$$c$$$ $$$d$$$

      $$$3$$$ $$$1$$$ $$$e$$$

      The equations are:

      • $$$a + 5 = x$$$ — $$$(i)$$$
      • $$$b + c + d = x$$$ — $$$(ii)$$$
      • $$$e + 4 = x$$$ — $$$(iii)$$$
      • $$$a + b + 3 = x$$$ — $$$(iv)$$$
      • $$$c + 3 = x$$$ — $$$(v)$$$
      • $$$d + e + 3 = x$$$ — $$$(vi)$$$

      Now, realize that the equations $$$(i)$$$ + $$$(ii)$$$ + $$$(iii)$$$ — $$$(iv)$$$ — $$$(v)$$$ = $$$(vi)$$$

      So equation $$$(vi)$$$ is not giving any new information, it can be derived from the first $$$5$$$ equations.

      So we can conclude that there are $$$n + m$$$ variables and $$$< n + m$$$ equations. So there are infinite combinations of values satisfying these equations, and we have to choose the easiest calculable solution of them.

      • »
        »
        »
        »
        6 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        I would argue that this only happens because, in the first sample, the grid is a square. In any other case, there is exactly one solution for all variables (x = 0)

        • »
          »
          »
          »
          »
          6 weeks ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          See it this way, in the first $$$n$$$ equations, each number is considered once.

          In the next $$$m - 1$$$ equations, we'll have each number from the first $$$m - 1$$$ columns.

          So subtracting the $$$n$$$ equations with the $$$m - 1$$$ equations gives the $$$m$$$-th equation.

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

First three problems are awesome <3

»
6 weeks ago, # |
  Vote: I like it +1 Vote: I do not like it

cout << (long long)2*tim << endl; cost me an AC in D

It should have been cout << (long long)(2*tim) << endl;

Very Dumb of me obviously to write that , even very dumb of me to not recognise it in my 15 mins debugging.

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

What is the proof for x=0 working for all test cases? The editorial without the proof doesn't make much sense. Also, are there any other values of x that will work for cases where n==m?

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

c was good

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Can anyone help me with todays B 2055B - Crafting.

My thought was: 300755890 We cannot increase more than one element for sure, why? Because if we try to increase A and B then we will inc. A then we have to dec B by atleast 1 and to inc B by 2 now we have to dec A by 2.

My second observation was that as the inc is dependent on dec so I calulated the minimum decrease that we can do and the max increase that we have to do although it is the single element. Now if the max increase is greater than the min decrease that we can bear than the ans in simply no.

for rest of the cases we can do the task so the ans is yes.

Can anyone please help me where I went wrong ?

Am I too dumb to ask this shit ?

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    a[i]>b[i] should be a[i]>=b[i]

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Thank you!. Would you please suggest what should I do in order to get rid of this silly mistakes.

      I have tears in my eyes but I can't cry .

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

EF are way harder than it should be. I've never seen a *3000 div2E.

»
6 weeks ago, # |
  Vote: I like it +16 Vote: I do not like it

Problem Haystacks is so cool, I love it <3

»
6 weeks ago, # |
  Vote: I like it +5 Vote: I do not like it

innocentkitten the implementations are not visible, we "aren't allowed to view the requested page"

»
6 weeks ago, # |
Rev. 5   Vote: I like it +4 Vote: I do not like it

For me, an easier way to reason about problem D is to think of two cases:

  1. The current scarecrow is to the right, in which case we:
    • bring it closer to the crow by "spending" the time accumulated so far;
    • bring the previous and current scarecrows closer to each other, by half the distance between the crow and the latter, updating the elapsed time as necessary;
    • move the crow forward by $$$k$$$ units plus the distance from the previous step.
  2. The current scarecrow is to the left, in which case we:
    • bring it closer to the crow by "spending" the time accumulated so far;
    • move the crow forward by $$$k$$$ units minus the distance from the previous step (which must be less than $$$k$$$).

At the end, if there remains any distance, the last scarecrow must move forward by that distance (adding to the elapsed time). The special case of the first scarecrow can be handled before the main loop. 300755131

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

WA 4 times and wasted almost 30 mins cause of '=' in problem B

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Trying to learn from every contest and seeking improvement to reach the level of Expert one day.

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

I changed the code for being sum =0 then also it give wrong ans at case 5k in test case 2 .....can you say why....300746771

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

I am really disappointed by how nowadays contests are formed, do guys from 1400-1800 have no oppurutunity to solve problems involving some Data structure or algo, I mean this level of greedy upto D, i mean we should give some advantage to guys who have read something extra over heavily intelligent guys who are gud at observing or greedy.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    remember people complaining last week why segment tree was required for D. i guess there will always be people complaining about smth

    • »
      »
      »
      6 weeks ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      I understand your point, but my complaint was very generic like not so intelligent guys like me wants to solve graphs or maybe any DS in C or D, maybe I will also not like Segment tree but that will not be a complaint from my side bcse I think segment tree for D is sometimes okay.

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

https://codeforces.me/contest/2055/submission/300760875

why Am I getting wrong answer here, please someone tell whats wrong, I did almost same thing as everyone did

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

In Problem C

Can it be proven that when n=m the solution x=0 is also possible?

»
6 weeks ago, # |
  Vote: I like it +1 Vote: I do not like it

I appreciate the detailed editorial with hints and everything... also, I enjoyed the contest! :D

»
6 weeks ago, # |
Rev. 2   Vote: I like it +1 Vote: I do not like it

In C, why is it correct to assert S × n = S × m? Why does the sum of the sum of the rows need to be equal to that of the columns? Oh, I get it, it's just the sum of the grid

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

For problem D, is anyone able to help figure out a counter case for my submission where the answer should be 1 but I get 2? https://codeforces.me/contest/2055/submission/300762828. I'm failing on the 2727th test case somehow

»
6 weeks ago, # |
  Vote: I like it +1 Vote: I do not like it

Nice explanation for problem C, I just guessed that setting x = 0 will work but wasn't able to prove why.

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Very high quality C and D, loved the round

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

what bothered me in this contest were the weak samples which caused me to get a lot of penalty. in A we'd pass the sample just checking whether they're adjacent. in B we'd pass the sample just checking the first material. at the end of the day it was just skill issue from my part, but still wish the samples were a bit more descriptive

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

For problem C: The fact that $$$S = 0$$$ will hold when $$$n = m$$$ is not trivial and the editorial's argument is not sufficient for that.

One argument for $$$m = n$$$ is that there are $$$n+m$$$ variables ($$$n+m-1$$$ on the path and $$$1$$$ which is $$$S$$$) but the $$$n+m$$$ linear equations are not linearly independent (since $$$m=n$$$, sum of all columns equal sum of all rows). So, we can pick $$$S$$$ to be anything we want since there are only $$$n+m-1$$$ linearly independent equations.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Can you please explain what did you just said, I can't really wrap my head around this

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    For $$$n = m$$$, it is solvable for any choice of $$$S$$$.

»
6 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Hey does anyone know why 300769418 doesn't work?

»
6 weeks ago, # |
Rev. 2   Vote: I like it +3 Vote: I do not like it

For D, you can multiply l, k, and the entries of a by 2 (but keep the speed at 1), so that you don't need to work with doubles.

Also, the solution to D is well-written, thanks!

»
6 weeks ago, # |
  Vote: I like it +10 Vote: I do not like it

Problem A is identical to an atcoder task: https://atcoder.jp/contests/agc020/tasks/agc020_a

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    ah, unfortunate. Given that the problem idea is relatively standard it's not a surprise it's come up before... but since it's problem A there isn't much to be done. Sorry about that.

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Why should we have S.n = S.m ?

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Here's the other way to implement the last part of problem E, which is simpler I'd say. Basically we choose the last haystack in the following way:

If we have a haystack with $$$b_i \le a_i$$$ which can be used as the final haystack, then it's not worse to use it as the last haystack, so we use it and calculate the answer.

Otherwise let $$$f_i$$$ be $$$a_i + \sum_{j<i} b_j - a_j$$$, and let $$$g_i = min_{i \le j}(f_j)$$$, then if we move the $$$i$$$-th haystack to the end (if possible) the answer will increase by $$$max(0, b_i - a_i - g_{i+1})$$$. So we choose a haystack that minimizes it.

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

In problem E, can someone elaborate on why this part holds true? "It is not hard to show that all such σ satisfying these properties are optimal by following similar logic as above."

»
6 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

MY Solution for C : Link (https://codeforces.me/contest/2055/submission/300723538) I write code in Java but found tle for this then is used chatgpt to convert. This contest was more c++ friendly

»
6 weeks ago, # |
Rev. 4   Vote: I like it +3 Vote: I do not like it

Hi Everyone, Here is my intuition for C

I made a linear equation (n + m ) * x = 2 * (total_sum_grid)

(n + m)*x = 2 * (partial_sum + y)

let (n +m) = p , partial_sum = q;

p*x = 2 * (q + y)

p.x = 2.q + 2.y

p.x — 2.y = 2.q (here we know the p , q values)

so after generating equations for test cases I felt this linear equation will always have solutions and x, y values can be any ranging {0 infinity}. So here I was stuck for 20min how can I pick x from this at some point I thought it could be done with binary search but then I realized it won't form 000000011111. since I got stuck I though let's start with a simple thought by fixing x = 0 , I tried few test cases and it is always balancing all rows and columns. But at this point I don't have prof why sticking to x = 0 will work but after few test cases I felt x = 0 will always work (I just assumed my prof as since all column's and rows have same sum and because of the given path I thought I can always adjust all columns and rows as I have few positions to adjust but I know this is not a nice way to prove). Now my issue is how can I implement it as of now from my observations I have x = 0 but how can I traverse the grid in such a way that rows and columns will be adjusted. Then I thought of what is the use of the given path and what will happen when we fix one element in the path given. Here I could see we can always fix a row or column as 0 based on our next step as given in the editorial as we never going to return back to either a row or column. At this point I got confidence that we can always adjust x = 0 why because the path will traverse in such a way that all columns and rows will be adjusted if we travel along the path(as path covers all rows and columns). Even though I got AC on this but after seeing editorial I felt i am just lucky. **I don't know should I feel happy or sad about my solution **.I will be happy with any of yours suggestions. ThankYou.

mysolution 300780643 TC = (N*M + N + M)

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Can someone help me with the submission: 300793550

I had similar approach, just the change being rather than calculating sum everytime, I had stored and updated it after every iteration.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Nvm got it, silly mistake had int in one place instead of ll

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Can someone tell the exact movements in last test case of the sample test case ?

  • »
    »
    6 weeks ago, # ^ |
    Rev. 4   Vote: I like it +4 Vote: I do not like it

    Suppose you are talking about D,

    $$$n,k,l = 9, 12, 54$$$

    when $$$t=0$$$, scarecrows: 3 3 8 24 25 27 29 34 53 crow: 0

    At $$$t=3$$$, scarecrows: 0 6 11 21 28 30 32 37 50 crow: 12->18->23->33->40->42->44->49

    Then, at $$$t=3.5$$$ scarecrows: 0 6 11 21 28 30 32 37.5 49.5 crow: 49->49.5->61.5

»
6 weeks ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

How can we proove that for S = 0 there will always be some solution ? Oh got it now we are provided that initially magic property hold So for n != m we are sure that the answer will always be there and S will be equal to 0 but how can we be sure that for n == m, S = 0 solution will exsist ?

»
6 weeks ago, # |
  Vote: I like it +8 Vote: I do not like it

D was amazing

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

I tried binary search for problem D, check for max time T then adjusting scarecrow positions greedily to give max push in right direction 300834214

but not sure why it's failing :(

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

woah that was fast! we've been getting lots of quick editorials lately, nice!

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

too fast

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Can anyone tell me why this 300740665 solution giving wa in tc2

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Some values are still 0 after you do the operations. Consider RDRDRDRDRD... So going row by row: We can't have an answer for row1, row2, row3, row4 and so on Similarly for column, col1 will have the answer but col2, col3, col4 and so on In this case if you do alternate col to row it will work(only in this case). There can be more cases. Come up with some general algorithm.

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

I have WA on B with similar logic as in solution: https://codeforces.me/contest/2055/submission/300902104 — help plz

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

D is too clever and too difficult for me.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    bro is there any extension exist that can give me problem from CF just to solve div 2 C or D problem

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

i really like the editorials that contain hint1,hint2 and then finally solution and implementations.

»
5 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

How is the 9th test case of problem D has the answer 7??

Can anyone explain?

Thanks!!

»
5 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it
My Observation for problem D
Reasoning
Submission
»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

I found the editorial a bit complicated to read so I decided to create a video tutorial on problem D. Scarecrow. https://youtu.be/FJ-X6pq1guk?si=u0lQVgWVjaAtHIVu

Sorry for the bad audio, i am not good with editing.

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

I think for D editorial is a bit complicated. We can simple move scarecrows to the position where crow will be after meeting the previous scarecrow. submission

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

For problem C, why does my code give TLE, even though it's O(n.m)? 301247612

I'm just keeping a track of the total sum of each row, column; and the number of Zero-ed cells, so that I can determine whether to use the row or column to find the negative sum for each cell in the path.

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

What is wrong with this submission problem C

https://codeforces.me/contest/2055/submission/300861460

»
5 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

For problem E, 6th test case, can someone explain me how to get 15, I keep getting 16.

6th test case:

5

3 2

1 2

1 1

1 3

6 5

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

I felt B so hard and im stuck at newbie,what should I do.Everyone is saying something.

»
5 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Here's a fun way to skip the optimality claim in E:

The problem is numerically stable, which means we can add infinitesimals to $$$a_i$$$ and $$$b_i$$$ and get essentially the same answer (well, we can't, because $$$a_i$$$ and $$$b_i$$$ are integers, but we can just work with the continuous version of the problem, where we move $$$x$$$ haybales for possibly non-integer cost $$$x$$$).

So if we replace $$$a_i$$$ by $$$a_i + i \varepsilon$$$ and $$$b_i$$$ by $$$b_i - i \varepsilon$$$, $$$\min(a_j, b_i)$$$ and $$$\min(a_i, b_j)$$$ are never equal. Since $$$<_{*} := \min(a_j, b_i) \geq \min(a_i, b_j)$$$ is transitive, we can go ahead and just sort the elements to get $$$\sigma$$$.

...it's probably easier to come up with the constructive solution anyway.

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

I've encountered a tricky problem. These four pieces of code only differ in the comparison function when a_i=b_i, but they yield different results. The comparison function should have no impact.Someone please help me.[submission:301500898][submission:301502091][submission:301501960][submission:301501852]

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Subject: Clarification Regarding Similarity in Solution for Problem 2055B

Hello,

I received a message regarding the similarity between my solution (Solution ID: 300728702) and another solution (Gaurav1937/300728161, Aman75641/300728702) for problem 2055B in this contest.

I want to clarify that my solution was written independently during the contest. I did not share my code or access any external sources during the competition. The logic I implemented is a natural approach to solving the problem, and any similarity could be coincidental due to the nature of the problem.

Key points I’d like to highlight:

My solution strictly adheres to my usual coding style, which can be observed in my previous submissions. I did not use any public platforms, such as Ideone, or share my code with others. If necessary, I can provide additional details about my thought process and how I arrived at the solution. I kindly request the Codeforces team to review the case thoroughly. Please let me know if any further information is required from my side.

Thank you for your understanding and for maintaining the integrity of the platform.

Best regards, Aman75641