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)?
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
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.me/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.me/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.me/contest/1855/problem/C1 (one of the recent div2 contests)
submission link : https://codeforces.me/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?
Название |
---|