# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
280416 |
2020-08-22T18:05:36 Z |
Saboon |
Wombats (IOI13_wombats) |
C++14 |
|
7162 ms |
135000 KB |
#include "wombats.h"
#include<bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int T = 20;
int M, R, C, H[5000][200], V[5000][200];
int bl[255][200][200], dp[1026][200][200], opt[200][200];
void change(int id, int L, int R, int idx){
if (idx < L or R <= idx)
return;
if (L + 1 == R){
for (int i = 0; i < C; i++)
for (int j = 0; j < C; j++)
dp[id][i][j] = bl[L][i][j];
return;
}
int mid = (L + R) >> 1;
change(2*id+0, L, mid, idx);
change(2*id+1, mid, R, idx);
for (int i = 0; i < C; i++){
for (int j = C-1; j >= 0; j--){
int lo = 0, hi = C-1;
if (j+1 < C)
hi = opt[i][j+1];
if (i > 0)
lo = opt[i-1][j];
dp[id][i][j] = inf;
for (int x = lo; x <= hi; x++){
if (dp[id][i][j] > dp[2*id+0][i][x] + dp[2*id+1][x][j]){
dp[id][i][j] = dp[2*id+0][i][x] + dp[2*id+1][x][j];
opt[i][j] = x;
}
}
}
}
}
void ChangeBlock(int block){
for (int j = 0; j < C; j++){
for (int k = 0; k < C; k++)
bl[block][j][k] = inf;
bl[block][j][j] = 0;
for (int k = j+1; k < C; k++)
bl[block][j][k] = bl[block][j][k-1] + H[T*block][k-1];
for (int k = j-1; k >= 0; k--)
bl[block][j][k] = bl[block][j][k+1] + H[T*block][k];
for (int k = 0; k < C; k++)
bl[block][j][k] += V[T*block][k];
for (int i = T*block+1; i < min(R, T*(block+1)); i++){
for (int k = 1; k < C; k++)
bl[block][j][k] = min(bl[block][j][k], bl[block][j][k-1] + H[i][k-1]);
for (int k = C-2; k >= 0; k--)
bl[block][j][k] = min(bl[block][j][k], bl[block][j][k+1] + H[i][k]);
for (int k = 0; k < C; k++)
bl[block][j][k] += V[i][k];
}
}
}
void init(int r, int c, int h[5000][200], int v[5000][200]){
M = (r-1)/T + 1;
R = r, C = c;
for (int i = 0; i < 5000; i++)
for (int j = 0; j < 200; j++)
H[i][j] = h[i][j], V[i][j] = v[i][j];
for (int i = 0; i < R; i += T)
ChangeBlock(i/T);
for (int i = 0; i < M; i++)
change(1, 0, M, i);
}
void changeH(int P, int Q, int W){
H[P][Q] = W;
ChangeBlock(P/T);
change(1, 0, M, P/T);
}
void changeV(int P, int Q, int W){
V[P][Q] = W;
ChangeBlock(P/T);
change(1, 0, M, P/T);
}
int escape(int V1, int V2){
return dp[1][V1][V2];
}
Compilation message
grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
15 | int res;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
15232 KB |
Output is correct |
2 |
Correct |
11 ms |
15232 KB |
Output is correct |
3 |
Correct |
103 ms |
16888 KB |
Output is correct |
4 |
Correct |
11 ms |
15232 KB |
Output is correct |
5 |
Correct |
11 ms |
15232 KB |
Output is correct |
6 |
Correct |
7 ms |
8192 KB |
Output is correct |
7 |
Correct |
8 ms |
8192 KB |
Output is correct |
8 |
Correct |
6 ms |
8192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
8192 KB |
Output is correct |
2 |
Correct |
6 ms |
8192 KB |
Output is correct |
3 |
Correct |
7 ms |
8192 KB |
Output is correct |
4 |
Correct |
7 ms |
8192 KB |
Output is correct |
5 |
Correct |
7 ms |
8192 KB |
Output is correct |
6 |
Correct |
7 ms |
8192 KB |
Output is correct |
7 |
Correct |
7 ms |
8192 KB |
Output is correct |
8 |
Correct |
7 ms |
8192 KB |
Output is correct |
9 |
Correct |
7 ms |
8192 KB |
Output is correct |
10 |
Correct |
7 ms |
8192 KB |
Output is correct |
11 |
Correct |
94 ms |
9212 KB |
Output is correct |
12 |
Correct |
7 ms |
8192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
210 ms |
9588 KB |
Output is correct |
2 |
Correct |
200 ms |
9592 KB |
Output is correct |
3 |
Correct |
212 ms |
9592 KB |
Output is correct |
4 |
Correct |
212 ms |
9472 KB |
Output is correct |
5 |
Correct |
203 ms |
9472 KB |
Output is correct |
6 |
Correct |
7 ms |
8192 KB |
Output is correct |
7 |
Correct |
7 ms |
8192 KB |
Output is correct |
8 |
Correct |
6 ms |
8192 KB |
Output is correct |
9 |
Correct |
944 ms |
9592 KB |
Output is correct |
10 |
Correct |
7 ms |
8192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
19712 KB |
Output is correct |
2 |
Correct |
14 ms |
19712 KB |
Output is correct |
3 |
Correct |
17 ms |
19840 KB |
Output is correct |
4 |
Correct |
57 ms |
20600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
207 ms |
9592 KB |
Output is correct |
2 |
Correct |
198 ms |
9472 KB |
Output is correct |
3 |
Correct |
208 ms |
9592 KB |
Output is correct |
4 |
Correct |
211 ms |
9592 KB |
Output is correct |
5 |
Correct |
205 ms |
9592 KB |
Output is correct |
6 |
Correct |
14 ms |
19712 KB |
Output is correct |
7 |
Correct |
14 ms |
19712 KB |
Output is correct |
8 |
Correct |
14 ms |
19712 KB |
Output is correct |
9 |
Correct |
57 ms |
20600 KB |
Output is correct |
10 |
Correct |
11 ms |
15488 KB |
Output is correct |
11 |
Correct |
14 ms |
15232 KB |
Output is correct |
12 |
Correct |
96 ms |
16888 KB |
Output is correct |
13 |
Correct |
12 ms |
15232 KB |
Output is correct |
14 |
Correct |
13 ms |
15360 KB |
Output is correct |
15 |
Correct |
7 ms |
8192 KB |
Output is correct |
16 |
Correct |
7 ms |
8192 KB |
Output is correct |
17 |
Correct |
7 ms |
8192 KB |
Output is correct |
18 |
Correct |
7 ms |
8192 KB |
Output is correct |
19 |
Correct |
7 ms |
8192 KB |
Output is correct |
20 |
Correct |
7 ms |
8192 KB |
Output is correct |
21 |
Correct |
7 ms |
8192 KB |
Output is correct |
22 |
Correct |
7 ms |
8320 KB |
Output is correct |
23 |
Correct |
7 ms |
8224 KB |
Output is correct |
24 |
Correct |
7 ms |
8192 KB |
Output is correct |
25 |
Correct |
99 ms |
9208 KB |
Output is correct |
26 |
Correct |
8 ms |
8192 KB |
Output is correct |
27 |
Correct |
945 ms |
9720 KB |
Output is correct |
28 |
Correct |
1864 ms |
77888 KB |
Output is correct |
29 |
Correct |
1788 ms |
65656 KB |
Output is correct |
30 |
Correct |
1763 ms |
65628 KB |
Output is correct |
31 |
Correct |
1892 ms |
78948 KB |
Output is correct |
32 |
Correct |
7 ms |
8192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
212 ms |
9708 KB |
Output is correct |
2 |
Correct |
200 ms |
9600 KB |
Output is correct |
3 |
Correct |
219 ms |
9592 KB |
Output is correct |
4 |
Correct |
216 ms |
9592 KB |
Output is correct |
5 |
Correct |
210 ms |
9592 KB |
Output is correct |
6 |
Correct |
17 ms |
19712 KB |
Output is correct |
7 |
Correct |
15 ms |
19840 KB |
Output is correct |
8 |
Correct |
15 ms |
19840 KB |
Output is correct |
9 |
Correct |
57 ms |
20600 KB |
Output is correct |
10 |
Correct |
11 ms |
15232 KB |
Output is correct |
11 |
Correct |
11 ms |
15232 KB |
Output is correct |
12 |
Correct |
98 ms |
16888 KB |
Output is correct |
13 |
Correct |
12 ms |
15232 KB |
Output is correct |
14 |
Correct |
11 ms |
15360 KB |
Output is correct |
15 |
Correct |
2512 ms |
133476 KB |
Output is correct |
16 |
Correct |
7162 ms |
135000 KB |
Output is correct |
17 |
Correct |
7 ms |
8192 KB |
Output is correct |
18 |
Correct |
7 ms |
8192 KB |
Output is correct |
19 |
Correct |
6 ms |
8192 KB |
Output is correct |
20 |
Correct |
7 ms |
8192 KB |
Output is correct |
21 |
Correct |
7 ms |
8192 KB |
Output is correct |
22 |
Correct |
7 ms |
8192 KB |
Output is correct |
23 |
Correct |
7 ms |
8192 KB |
Output is correct |
24 |
Correct |
7 ms |
8192 KB |
Output is correct |
25 |
Correct |
7 ms |
8192 KB |
Output is correct |
26 |
Correct |
7 ms |
8192 KB |
Output is correct |
27 |
Correct |
93 ms |
9208 KB |
Output is correct |
28 |
Correct |
7 ms |
8192 KB |
Output is correct |
29 |
Correct |
965 ms |
9592 KB |
Output is correct |
30 |
Correct |
1842 ms |
78212 KB |
Output is correct |
31 |
Correct |
6818 ms |
134120 KB |
Output is correct |
32 |
Correct |
6827 ms |
134084 KB |
Output is correct |
33 |
Correct |
1759 ms |
65624 KB |
Output is correct |
34 |
Correct |
6684 ms |
111984 KB |
Output is correct |
35 |
Correct |
1770 ms |
65748 KB |
Output is correct |
36 |
Correct |
6702 ms |
112212 KB |
Output is correct |
37 |
Correct |
1898 ms |
79172 KB |
Output is correct |
38 |
Correct |
6941 ms |
134812 KB |
Output is correct |
39 |
Correct |
7 ms |
8192 KB |
Output is correct |
40 |
Correct |
6904 ms |
111864 KB |
Output is correct |