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

Автор innocentkitten, 9 часов назад, По-английски

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
Разбор задач Codeforces Round 996 (Div. 2)
  • Проголосовать: нравится
  • +70
  • Проголосовать: не нравится

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

fast editorial...orz

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

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

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

c was cool

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

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

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

oh wow, thank you for fast editorial

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

What in the Itachi Crow Montage D problem :}

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

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.

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

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

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

    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?

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

    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

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

I never thought that Problem D is a Greedy!

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

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

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

    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 :)

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

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.

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

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

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

    I tried to use binary search for C as well here: https://mirror.codeforces.com/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$$$.

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

      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.

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

        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.

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

C was, brutal not gonna lie!

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

    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!

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

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.

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

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

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

      https://mirror.codeforces.com/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

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

        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.

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

        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

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

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

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

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

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

    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

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

      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

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

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

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

E and F so hard.

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

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

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

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

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

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

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

Problem C is really amazing.

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

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

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

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;
    }
}
  • »
    »
    9 часов назад, # ^ |
    Rev. 4   Проголосовать: нравится 0 Проголосовать: не нравится

    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 ).

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

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.

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

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!

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

sorry i misread the turorial and made a dum comment

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

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

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

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.

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

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?

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

    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

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

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

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

    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

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

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

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

Solved C before B. I should really think before implementing

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

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

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

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.

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

feeling happy after climbing mountains of problem C

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

Guys, will i reach specialist today?

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

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

orz. amazing!!

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

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?

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

    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.

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

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

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

    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 :)

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

      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

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

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

(https://mirror.codeforces.com/contest/2055/submission/300707536)

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

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

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

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.

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

First three problems are awesome <3

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

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.

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

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?

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

c was good

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

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 ?

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

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

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

Problem Haystacks is so cool, I love it <3

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

https://mirror.codeforces.com/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 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

In Problem C

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

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

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

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

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

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

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://mirror.codeforces.com/contest/2055/submission/300762828. I'm failing on the 2727th test case somehow

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

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

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

Very high quality C and D, loved the round

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

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

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

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.

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

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

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

Hey does anyone know why 300769418 doesn't work?

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

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!

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

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

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

    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.

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

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

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

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.

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

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."