Comments

Why in D, statement is written very very confusing??? "After you decide how to deal with all the offers, the actual Billion Players Game is played." After that i started solving the problem thinking first you decide, then value in [L, R] is given. BUT it was oppsosite and very easy ):

Auto comment: topic has been updated by Muhammadali__ (previous revision, new revision, compare).

On vaavenCodeforces Round 1031 (Div. 2), 12 months ago
0

shitty contest

Thanks!

Thank you!

Can someone share beautiful and clean code for D1?

The solution for problem C does not look good, ig. Can you write a more beautiful and clearer code?

I think you misunderstood, we can move only to the down or right and thats not about shifts : we already know how many shifts we did and tmp[i] is the ith row AFTER shifts. so we can simply write : tmp[j] = min(tmp[j],tmp[j-1] + a[i][(j+shift)%m]) (if you still did not understand, proof is -> code, you can submit it)

also tmp[(j-1)%m] can be changed to tmp[j-1](more clear...)

for D the second same for is unnecessary and also there is no path from [i][m — 1] to [i][1] so there is no need to write tmp[(j+m-1)%m]

so simpler code is:

for(int i=1;i<=n;i++){
    for(int shift = 0;shift<m;shift++){
        vector<ll>tmp(m,1e18);
        for(int j=0;j<m;j++)tmp[j] = dp[i-1][j] + a[i][(j+shift)%m] + k*1LL*shift;

        for(int j=1;j<m;j++)tmp[j] = min(tmp[j],tmp[(j-1)%m] + a[i][(j+shift)%m]);
        for(int j=0;j<m;j++)dp[i][j] = min(dp[i][j],tmp[j]);
    }
}

(100% correct)