# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
280211 |
2020-08-22T14:59:34 Z |
Saboon |
Wombats (IOI13_wombats) |
C++14 |
|
20000 ms |
29888 KB |
#include "wombats.h"
#include<bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int T = 100;
int R, C, H[5000][200], V[5000][200];
int bl[55][200][200], dp[2][200][200];
bool mark[200];
void calc(int l, int r, int lo, int hi, int block, int V1){
if (l >= r)
return;
int m = (l+r) >> 1, opt = -1;
dp[1][V1][m] = inf;
for (int i = lo; i < hi; i++){
if (dp[0][V1][i] + bl[block][i][m] < dp[1][V1][m]){
opt = i;
dp[1][V1][m] = dp[0][V1][i] + bl[block][i][m];
}
}
calc(l, m, lo, opt+1, block, V1);
calc(m+1, r, opt, hi, block, V1);
}
void MakeAll(int V1){
for (int i = 0; i < C; i++)
dp[0][V1][i] = bl[0][V1][i];
for (int i = T; i < R; i += T){
int block = i/T;
calc(0, C, 0, C, block, V1);
for (int j = 0; j < C; j++)
dp[0][V1][j] = dp[1][V1][j];
}
mark[V1] = 1;
}
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]){
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);
return;
}
void changeH(int P, int Q, int W){
H[P][Q] = W;
ChangeBlock(P/T);
memset(mark, 0, sizeof mark);
}
void changeV(int P, int Q, int W){
V[P][Q] = W;
ChangeBlock(P/T);
memset(mark, 0, sizeof mark);
}
int escape(int V1, int V2){
if (mark[V1])
return dp[0][V1][V2];
MakeAll(V1);
return dp[0][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 |
9 ms |
12288 KB |
Output is correct |
2 |
Correct |
9 ms |
12288 KB |
Output is correct |
3 |
Correct |
90 ms |
13944 KB |
Output is correct |
4 |
Correct |
10 ms |
12288 KB |
Output is correct |
5 |
Correct |
10 ms |
12288 KB |
Output is correct |
6 |
Correct |
7 ms |
8192 KB |
Output is correct |
7 |
Correct |
8 ms |
8168 KB |
Output is correct |
8 |
Correct |
8 ms |
8192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
8192 KB |
Output is correct |
2 |
Correct |
7 ms |
8192 KB |
Output is correct |
3 |
Correct |
6 ms |
8192 KB |
Output is correct |
4 |
Correct |
7 ms |
8192 KB |
Output is correct |
5 |
Correct |
10 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 |
8 ms |
8192 KB |
Output is correct |
9 |
Correct |
7 ms |
8192 KB |
Output is correct |
10 |
Correct |
8 ms |
8192 KB |
Output is correct |
11 |
Correct |
96 ms |
9272 KB |
Output is correct |
12 |
Correct |
7 ms |
8192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
969 ms |
8448 KB |
Output is correct |
2 |
Correct |
961 ms |
8568 KB |
Output is correct |
3 |
Correct |
987 ms |
8448 KB |
Output is correct |
4 |
Correct |
950 ms |
8448 KB |
Output is correct |
5 |
Correct |
980 ms |
8448 KB |
Output is correct |
6 |
Correct |
9 ms |
8192 KB |
Output is correct |
7 |
Correct |
8 ms |
8192 KB |
Output is correct |
8 |
Correct |
7 ms |
8192 KB |
Output is correct |
9 |
Correct |
4964 ms |
8460 KB |
Output is correct |
10 |
Correct |
8 ms |
8192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
16292 KB |
Output is correct |
2 |
Correct |
19 ms |
16248 KB |
Output is correct |
3 |
Correct |
16 ms |
16256 KB |
Output is correct |
4 |
Correct |
60 ms |
17048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
971 ms |
8448 KB |
Output is correct |
2 |
Correct |
934 ms |
8612 KB |
Output is correct |
3 |
Correct |
964 ms |
8504 KB |
Output is correct |
4 |
Correct |
967 ms |
8572 KB |
Output is correct |
5 |
Correct |
962 ms |
8448 KB |
Output is correct |
6 |
Correct |
15 ms |
16256 KB |
Output is correct |
7 |
Correct |
15 ms |
16256 KB |
Output is correct |
8 |
Correct |
17 ms |
16256 KB |
Output is correct |
9 |
Correct |
83 ms |
17016 KB |
Output is correct |
10 |
Correct |
11 ms |
12288 KB |
Output is correct |
11 |
Correct |
10 ms |
12288 KB |
Output is correct |
12 |
Correct |
109 ms |
13924 KB |
Output is correct |
13 |
Correct |
13 ms |
12288 KB |
Output is correct |
14 |
Correct |
10 ms |
12288 KB |
Output is correct |
15 |
Correct |
6 ms |
8192 KB |
Output is correct |
16 |
Correct |
7 ms |
8192 KB |
Output is correct |
17 |
Correct |
6 ms |
8192 KB |
Output is correct |
18 |
Correct |
7 ms |
8192 KB |
Output is correct |
19 |
Correct |
10 ms |
8192 KB |
Output is correct |
20 |
Correct |
10 ms |
8196 KB |
Output is correct |
21 |
Correct |
7 ms |
8192 KB |
Output is correct |
22 |
Correct |
7 ms |
8192 KB |
Output is correct |
23 |
Correct |
8 ms |
8192 KB |
Output is correct |
24 |
Correct |
8 ms |
8192 KB |
Output is correct |
25 |
Correct |
98 ms |
9260 KB |
Output is correct |
26 |
Correct |
8 ms |
8192 KB |
Output is correct |
27 |
Correct |
4740 ms |
8464 KB |
Output is correct |
28 |
Correct |
11916 ms |
20796 KB |
Output is correct |
29 |
Correct |
12469 ms |
18516 KB |
Output is correct |
30 |
Correct |
12799 ms |
18500 KB |
Output is correct |
31 |
Correct |
13668 ms |
24492 KB |
Output is correct |
32 |
Correct |
8 ms |
8192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1000 ms |
8664 KB |
Output is correct |
2 |
Correct |
971 ms |
8556 KB |
Output is correct |
3 |
Correct |
1035 ms |
8612 KB |
Output is correct |
4 |
Correct |
974 ms |
8728 KB |
Output is correct |
5 |
Correct |
953 ms |
8612 KB |
Output is correct |
6 |
Correct |
20 ms |
16256 KB |
Output is correct |
7 |
Correct |
19 ms |
16260 KB |
Output is correct |
8 |
Correct |
18 ms |
16256 KB |
Output is correct |
9 |
Correct |
74 ms |
17656 KB |
Output is correct |
10 |
Correct |
9 ms |
12288 KB |
Output is correct |
11 |
Correct |
12 ms |
12288 KB |
Output is correct |
12 |
Correct |
95 ms |
15080 KB |
Output is correct |
13 |
Correct |
12 ms |
12288 KB |
Output is correct |
14 |
Correct |
12 ms |
12288 KB |
Output is correct |
15 |
Correct |
2395 ms |
28992 KB |
Output is correct |
16 |
Execution timed out |
20059 ms |
29888 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |