# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
281562 |
2020-08-23T08:03:43 Z |
Kastanda |
Wombats (IOI13_wombats) |
C++11 |
|
7611 ms |
109048 KB |
// M
#include<bits/stdc++.h>
#include "wombats.h"
#define lc (id << 1)
#define rc (lc ^ 1)
#define md ((l + r) >> 1)
using namespace std;
const int N = 5005, M = 202, MXS = 512, SQ = 20, INF = 1e9 + 9;
int n, m, H[N][M], V[N][M];
int dp[MXS][M][M];
int TMp[M][M], Opt[M][M];
inline void BuildBlock(int l, int r)
{
memset(TMp, 63, sizeof(TMp));
for (int st = 0; st < m; st ++)
{
TMp[st][st] = 0;
for (int i = l; i < r; i ++)
{
for (int j = 1; j < m; j ++)
TMp[st][j] = min(TMp[st][j], TMp[st][j - 1] + H[i][j - 1]);
for (int j = m - 2; j >= 0; j --)
TMp[st][j] = min(TMp[st][j], TMp[st][j + 1] + H[i][j]);
for (int j = 0; j < m; j ++)
TMp[st][j] += V[i][j];
}
}
}
inline void Merge(int id, int le, int ri)
{
for (int sm = - m; sm < m; sm ++)
for (int st = 0; st < m; st ++)
{
int fn = sm + st;
if (fn < 0 || fn >= m)
continue;
int l = fn ? Opt[st][fn - 1] : 0;
int r = (st + 1 < m) ? Opt[st + 1][fn] : (m - 1);
int opt = -1, Mn = INF;
for (int i = l; i <= r; i ++)
if (Mn > dp[le][st][i] + dp[ri][i][fn])
Mn = dp[le][st][i] + dp[ri][i][fn], opt = i;
Opt[st][fn] = opt;
dp[id][st][fn] = Mn;
}
}
void BuildSegTree(int id = 1, int l = 0, int r = n)
{
if (r - l <= SQ)
{
BuildBlock(l, r);
memcpy(dp[id], TMp, sizeof(TMp));
return ;
}
BuildSegTree(lc, l, md);
BuildSegTree(rc, md, r);
Merge(id, lc, rc);
}
void init(int _n, int _m, int _H[5000][200], int _V[5000][200])
{
n = _n; m = _m;
for (int i = 0; i < n; i ++)
for (int j = 0; j + 1 < m; j ++)
H[i][j] = _H[i][j];
for (int i = 0; i + 1 < n; i ++)
for (int j = 0; j < m; j ++)
V[i][j] = _V[i][j];
BuildSegTree();
}
void Update(int i, int id = 1, int l = 0, int r = n)
{
if (r - l <= SQ)
{
BuildBlock(l, r);
memcpy(dp[id], TMp, sizeof(TMp));
return ;
}
if (i < md)
Update(i, lc, l, md);
else
Update(i, rc, md, r);
Merge(id, lc, rc);
}
void changeH(int r, int c, int w)
{
H[r][c] = w;
Update(r);
}
void changeV(int r, int c, int w)
{
V[r][c] = w;
Update(r);
}
int escape(int st, int fn)
{
return dp[1][st][fn];
}
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 |
45 ms |
50424 KB |
Output is correct |
2 |
Correct |
49 ms |
50296 KB |
Output is correct |
3 |
Correct |
126 ms |
51960 KB |
Output is correct |
4 |
Correct |
47 ms |
50296 KB |
Output is correct |
5 |
Correct |
46 ms |
50296 KB |
Output is correct |
6 |
Correct |
1 ms |
640 KB |
Output is correct |
7 |
Correct |
1 ms |
640 KB |
Output is correct |
8 |
Correct |
1 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
640 KB |
Output is correct |
2 |
Correct |
1 ms |
640 KB |
Output is correct |
3 |
Correct |
1 ms |
640 KB |
Output is correct |
4 |
Correct |
1 ms |
768 KB |
Output is correct |
5 |
Correct |
1 ms |
768 KB |
Output is correct |
6 |
Correct |
1 ms |
768 KB |
Output is correct |
7 |
Correct |
1 ms |
768 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
1 ms |
768 KB |
Output is correct |
10 |
Correct |
1 ms |
768 KB |
Output is correct |
11 |
Correct |
84 ms |
1784 KB |
Output is correct |
12 |
Correct |
1 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
159 ms |
2816 KB |
Output is correct |
2 |
Correct |
145 ms |
2936 KB |
Output is correct |
3 |
Correct |
176 ms |
2816 KB |
Output is correct |
4 |
Correct |
164 ms |
2904 KB |
Output is correct |
5 |
Correct |
157 ms |
2816 KB |
Output is correct |
6 |
Correct |
1 ms |
640 KB |
Output is correct |
7 |
Correct |
1 ms |
640 KB |
Output is correct |
8 |
Correct |
1 ms |
640 KB |
Output is correct |
9 |
Correct |
715 ms |
2936 KB |
Output is correct |
10 |
Correct |
1 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
58488 KB |
Output is correct |
2 |
Correct |
50 ms |
58488 KB |
Output is correct |
3 |
Correct |
54 ms |
58488 KB |
Output is correct |
4 |
Correct |
94 ms |
59896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
161 ms |
2820 KB |
Output is correct |
2 |
Correct |
156 ms |
2816 KB |
Output is correct |
3 |
Correct |
173 ms |
3004 KB |
Output is correct |
4 |
Correct |
161 ms |
2936 KB |
Output is correct |
5 |
Correct |
159 ms |
2816 KB |
Output is correct |
6 |
Correct |
52 ms |
58488 KB |
Output is correct |
7 |
Correct |
51 ms |
58496 KB |
Output is correct |
8 |
Correct |
54 ms |
58488 KB |
Output is correct |
9 |
Correct |
100 ms |
59896 KB |
Output is correct |
10 |
Correct |
46 ms |
50296 KB |
Output is correct |
11 |
Correct |
46 ms |
50424 KB |
Output is correct |
12 |
Correct |
130 ms |
53112 KB |
Output is correct |
13 |
Correct |
48 ms |
50296 KB |
Output is correct |
14 |
Correct |
45 ms |
50304 KB |
Output is correct |
15 |
Correct |
1 ms |
640 KB |
Output is correct |
16 |
Correct |
1 ms |
640 KB |
Output is correct |
17 |
Correct |
1 ms |
640 KB |
Output is correct |
18 |
Correct |
1 ms |
768 KB |
Output is correct |
19 |
Correct |
1 ms |
768 KB |
Output is correct |
20 |
Correct |
1 ms |
768 KB |
Output is correct |
21 |
Correct |
1 ms |
768 KB |
Output is correct |
22 |
Correct |
1 ms |
768 KB |
Output is correct |
23 |
Correct |
1 ms |
768 KB |
Output is correct |
24 |
Correct |
1 ms |
768 KB |
Output is correct |
25 |
Correct |
85 ms |
3064 KB |
Output is correct |
26 |
Correct |
1 ms |
768 KB |
Output is correct |
27 |
Correct |
721 ms |
3028 KB |
Output is correct |
28 |
Correct |
1911 ms |
82832 KB |
Output is correct |
29 |
Correct |
1734 ms |
79424 KB |
Output is correct |
30 |
Correct |
1751 ms |
79400 KB |
Output is correct |
31 |
Correct |
2033 ms |
84428 KB |
Output is correct |
32 |
Correct |
1 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
157 ms |
2792 KB |
Output is correct |
2 |
Correct |
147 ms |
2936 KB |
Output is correct |
3 |
Correct |
170 ms |
2904 KB |
Output is correct |
4 |
Correct |
184 ms |
2816 KB |
Output is correct |
5 |
Correct |
167 ms |
2816 KB |
Output is correct |
6 |
Correct |
52 ms |
58488 KB |
Output is correct |
7 |
Correct |
60 ms |
58492 KB |
Output is correct |
8 |
Correct |
53 ms |
58488 KB |
Output is correct |
9 |
Correct |
99 ms |
59884 KB |
Output is correct |
10 |
Correct |
45 ms |
50296 KB |
Output is correct |
11 |
Correct |
49 ms |
50300 KB |
Output is correct |
12 |
Correct |
129 ms |
53112 KB |
Output is correct |
13 |
Correct |
50 ms |
50424 KB |
Output is correct |
14 |
Correct |
45 ms |
50296 KB |
Output is correct |
15 |
Correct |
2349 ms |
107776 KB |
Output is correct |
16 |
Correct |
7611 ms |
109048 KB |
Output is correct |
17 |
Correct |
1 ms |
640 KB |
Output is correct |
18 |
Correct |
1 ms |
640 KB |
Output is correct |
19 |
Correct |
1 ms |
640 KB |
Output is correct |
20 |
Correct |
1 ms |
768 KB |
Output is correct |
21 |
Correct |
1 ms |
768 KB |
Output is correct |
22 |
Correct |
1 ms |
768 KB |
Output is correct |
23 |
Correct |
1 ms |
768 KB |
Output is correct |
24 |
Correct |
1 ms |
768 KB |
Output is correct |
25 |
Correct |
2 ms |
768 KB |
Output is correct |
26 |
Correct |
1 ms |
768 KB |
Output is correct |
27 |
Correct |
92 ms |
3192 KB |
Output is correct |
28 |
Correct |
1 ms |
768 KB |
Output is correct |
29 |
Correct |
712 ms |
2816 KB |
Output is correct |
30 |
Correct |
1927 ms |
82528 KB |
Output is correct |
31 |
Correct |
7447 ms |
106508 KB |
Output is correct |
32 |
Correct |
7409 ms |
106568 KB |
Output is correct |
33 |
Correct |
1745 ms |
79480 KB |
Output is correct |
34 |
Correct |
6644 ms |
103132 KB |
Output is correct |
35 |
Correct |
1790 ms |
79472 KB |
Output is correct |
36 |
Correct |
6722 ms |
102960 KB |
Output is correct |
37 |
Correct |
2118 ms |
84232 KB |
Output is correct |
38 |
Correct |
7599 ms |
107012 KB |
Output is correct |
39 |
Correct |
1 ms |
640 KB |
Output is correct |
40 |
Correct |
6993 ms |
103172 KB |
Output is correct |