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 | 3773 |
3 | Radewoosh | 3646 |
4 | ecnerwala | 3624 |
5 | jqdai0815 | 3620 |
5 | Benq | 3620 |
7 | orzdevinwang | 3612 |
8 | Geothermal | 3569 |
8 | cnnfls_csy | 3569 |
10 | gyh20 | 3447 |
# | User | Contrib. |
---|---|---|
1 | awoo | 161 |
2 | maomao90 | 160 |
3 | nor | 157 |
4 | atcoder_official | 156 |
4 | cry | 156 |
6 | -is-this-fft- | 155 |
7 | maroonrk | 154 |
8 | adamant | 153 |
9 | Um_nik | 151 |
10 | djm03178 | 146 |
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://mirror.codeforces.com/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://mirror.codeforces.com/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://mirror.codeforces.com/contest/1855/problem/C1 (one of the recent div2 contests)
submission link : https://mirror.codeforces.com/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 |
---|