I want to check a solution which I believe is wrong from yesterday's contest (Edu Round 161)
How can I hack/check that now (after the hacking phase)?
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3831 |
3 | Radewoosh | 3646 |
4 | jqdai0815 | 3620 |
4 | Benq | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | gamegame | 3386 |
10 | ksun48 | 3373 |
# | User | Contrib. |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 160 |
5 | -is-this-fft- | 158 |
6 | awoo | 157 |
7 | adamant | 156 |
8 | TheScrasse | 154 |
8 | nor | 154 |
10 | Dominater069 | 153 |
I want to check a solution which I believe is wrong from yesterday's contest (Edu Round 161)
How can I hack/check that now (after the hacking phase)?
Does anyone know where I can get USACO old problems?
I saw this blog on CF: https://codeforces.net/blog/entry/95032
But it prolly doesnt have the ones which arent on the official site (I tried accessing JAN 2011 questions, link isn't working)
The editorial at times becomes difficult to understand
I liked this blog from site: https://www.cnblogs.com/cjjsb/p/16882203.html
And translate does make it pretty understandable
Was curious, what are other different sites where the solutions get discussed? Maybe Chinese, Japanese..or any language as we can translate it
Coders from different regions can you drop in the sites you know/like to read
Question: https://codeforces.net/problemset/problem/1906/M
Editorial: https://competition.binus.ac.id/icpc2023/M5xmtK1iPAdXT1t765fbLg5m66d52XuT.pdf
The second part in the editorial where $$$M \le 2 \cdot (S - M)$$$
I read it, but still feel I don't quite get it.
Can someone please help me to understand the math of the second part
A boat can carry at max a weight of W
.
There are N
people, with weight w_i
.
Once the boat crosses the river it never returns.
We have to tell the no. of different groupings possible of people
Solve for T
testcases
T
N W
w_1, w_2, ... w_N
1 <= T <= 100
1 <= N <= 30
1 <= w_i, W <= 2 * 1e9
NOTE: not choosing any person and just passing the boat is also valid.
`Sample input`:
3
1 1
1
1 1
2
3 10
1 2 4
`Sample output`:
2
1
8
Can someone please help. Thank you
I am getting MLE for the question: https://codeforces.net/contest/1855/problem/C1 (one of the recent div2 contests)
submission link : https://codeforces.net/contest/1855/submission/217028542
The approach that I am trying:
1. To increase the positive element greater than 20
2. make the index-1 greater than 0 with the help of max value index. (0 based indexing)
3. now increase the values incrementally
I am getting problem for the case, where there is a positive number present in the array ( I know this because if I assert the size, I get the runtime error )
else{
ll mxidx = max_element(all(v)) - v.begin();
// 1. increasing the max element
while(v[mxidx] < 20) {
ans.pb(mp(mxidx, mxidx));
v[mxidx] += v[mxidx];
}
// 2. making the 2nd element greater than the 1st one
while(v[0] > v[1]) {
ans.pb(mp(1, mxidx));
v[1] += v[mxidx];
}
// 3. incrementally increasing the values for the rest
loop(i, 2, n) {
while(v[i-1] > v[i]) {
if(v[i-1] == 0) { // to handle cases like [-1, -20, -1, 20]
ans.pb(mp(i, mxidx));
v[i] += v[mxidx];
continue;
}
//assert(sz(ans) <= 50);
ans.pb(mp(i, i-1)) ;
v[i] += v[i-1];
}
}
}
Question https://cses.fi/problemset/task/1636/
My code: https://pastebin.com/Ex76qD5f
I know for some problems where in dp state, the transitions go from (i,j) -> (i+1, j) or (i, j) -> (i-1, j)
in this case we can make the dp storage as dp[2][maxJ]
instead of dp[maxI][maxJ]
But is there a way I can do the same when I have already written the code in recursive fashion?
or make just few changes to code so to apply this (i.e dp[2][maxJ]
) optimization, instead of writing the iterative code again to apply the optimization.
NOTE: I want to know if I can apply this optimization for a general case? Or it is necessary to write iterative code to apply it?
Name |
---|