# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
289343 |
2020-09-02T15:06:00 Z |
egekabas |
Wombats (IOI13_wombats) |
C++14 |
|
7664 ms |
182616 KB |
#include "wombats.h"
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
int r, c;
const int sq = 15;
int h[5000][200];
int v[5000][200];
int dis[5000/sq+5][200][200];
void dijkstra1(int beg, int end, int imp, int dis[200]){
for(int j = 0; j < c; ++j)
dis[j] = 1e9+7;
dis[imp] = 0;
for(int i = end; i >= beg; --i){
for(int j = 1; j < c; ++j)
dis[j] = min(dis[j], dis[j-1]+h[i][j-1]);
for(int j = c-2; j >= 0; --j)
dis[j] = min(dis[j], dis[j+1]+h[i][j]);
for(int j = 0; j < c && i != beg; ++j)
dis[j] = min((int)1e9+7, dis[j] + v[i-1][j]);
}
}
int cnt;
int segdis[(5000/sq)*4+5][200][200];
int opt[200][200];
void calc(int v, int tl, int tr, int idx){
if(tl == tr){
for(int i = 0; i < c; ++i)
for(int j = 0; j < c; ++j){
segdis[v][i][j] = dis[tl][j][i];
}
return;
}
int tm = (tl+tr)/2;
if(idx <= tm || idx == -1)
calc(2*v, tl, tm, idx);
if(idx > tm || idx == -1)
calc(2*v+1, tm+1, tr, idx);
for(int i = c-1; i >= 0; --i)
for(int j = 0; j < c; ++j){
int beg = 0, en = c-1;
if(i+1 < c)
en = opt[i+1][j];
if(j > 0)
beg = opt[i][j-1];
pii mini = {1e9+7, 1e9+7};
for(int k = beg; k <= en; ++k)
mini = min(mini, {segdis[2*v][i][k]+segdis[2*v+1][k][j], k});
segdis[v][i][j] = mini.ff;
opt[i][j] = mini.ss;
}
}
void init(int R, int C, int H[5000][200], int V[5000][200]) {
r = R;
c = C;
for(int i = 0; i < r; i += sq)
cnt = max(cnt, i/sq);
for(int i = 0; i < r; ++i)
for(int j = 0; j < c; ++j){
h[i][j] = H[i][j];
v[i][j] = V[i][j];
}
for(int i = 0; i < r; i += sq)
for(int j = 0; j < c; ++j)
dijkstra1(i, min(i+sq, r-1), j, dis[i/sq][j]);
calc(1, 0, cnt, -1);
}
vector<int> change;
void changeH(int P, int Q, int W) {
h[P][Q] = W;
int gr = P/sq;
change.pb(gr);
if(gr > 0 && P%sq == 0){
change.pb(gr-1);
}
}
void changeV(int P, int Q, int W) {
v[P][Q] = W;
int gr = P/sq;
change.pb(gr);
}
int curd[200];
int newd[200];
int done[sq+5];
int changed[200];
int escape(int V1, int V2) {
for(auto u : change){
if(done[u]) continue;
for(int j = 0; j < c; ++j)
dijkstra1(u*sq, min(r-1, (u+1)*sq), j, dis[u][j]);
calc(1, 0, cnt, u);
}
for(auto u : change)
done[u] = 0;
change.clear();
return segdis[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 |
16512 KB |
Output is correct |
2 |
Correct |
9 ms |
16640 KB |
Output is correct |
3 |
Correct |
95 ms |
18040 KB |
Output is correct |
4 |
Correct |
10 ms |
16512 KB |
Output is correct |
5 |
Correct |
9 ms |
16512 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
1 ms |
512 KB |
Output is correct |
7 |
Correct |
1 ms |
512 KB |
Output is correct |
8 |
Correct |
1 ms |
512 KB |
Output is correct |
9 |
Correct |
1 ms |
512 KB |
Output is correct |
10 |
Correct |
1 ms |
512 KB |
Output is correct |
11 |
Correct |
87 ms |
1784 KB |
Output is correct |
12 |
Correct |
1 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
185 ms |
2424 KB |
Output is correct |
2 |
Correct |
186 ms |
2552 KB |
Output is correct |
3 |
Correct |
204 ms |
2432 KB |
Output is correct |
4 |
Correct |
195 ms |
2680 KB |
Output is correct |
5 |
Correct |
195 ms |
2556 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
915 ms |
2560 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
21120 KB |
Output is correct |
2 |
Correct |
13 ms |
21248 KB |
Output is correct |
3 |
Correct |
13 ms |
21248 KB |
Output is correct |
4 |
Correct |
56 ms |
22136 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
186 ms |
2552 KB |
Output is correct |
2 |
Correct |
187 ms |
2552 KB |
Output is correct |
3 |
Correct |
203 ms |
2432 KB |
Output is correct |
4 |
Correct |
195 ms |
2476 KB |
Output is correct |
5 |
Correct |
197 ms |
2432 KB |
Output is correct |
6 |
Correct |
14 ms |
21248 KB |
Output is correct |
7 |
Correct |
12 ms |
21248 KB |
Output is correct |
8 |
Correct |
13 ms |
21248 KB |
Output is correct |
9 |
Correct |
57 ms |
22136 KB |
Output is correct |
10 |
Correct |
10 ms |
16512 KB |
Output is correct |
11 |
Correct |
10 ms |
16512 KB |
Output is correct |
12 |
Correct |
92 ms |
18300 KB |
Output is correct |
13 |
Correct |
10 ms |
16512 KB |
Output is correct |
14 |
Correct |
11 ms |
16512 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
0 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
512 KB |
Output is correct |
19 |
Correct |
1 ms |
512 KB |
Output is correct |
20 |
Correct |
1 ms |
512 KB |
Output is correct |
21 |
Correct |
1 ms |
512 KB |
Output is correct |
22 |
Correct |
1 ms |
512 KB |
Output is correct |
23 |
Correct |
1 ms |
512 KB |
Output is correct |
24 |
Correct |
1 ms |
512 KB |
Output is correct |
25 |
Correct |
87 ms |
1784 KB |
Output is correct |
26 |
Correct |
1 ms |
512 KB |
Output is correct |
27 |
Correct |
913 ms |
2552 KB |
Output is correct |
28 |
Correct |
1917 ms |
99064 KB |
Output is correct |
29 |
Correct |
1853 ms |
81144 KB |
Output is correct |
30 |
Correct |
1873 ms |
81404 KB |
Output is correct |
31 |
Correct |
1971 ms |
99704 KB |
Output is correct |
32 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
188 ms |
2544 KB |
Output is correct |
2 |
Correct |
187 ms |
2304 KB |
Output is correct |
3 |
Correct |
204 ms |
2424 KB |
Output is correct |
4 |
Correct |
193 ms |
2424 KB |
Output is correct |
5 |
Correct |
192 ms |
2304 KB |
Output is correct |
6 |
Correct |
13 ms |
21248 KB |
Output is correct |
7 |
Correct |
12 ms |
21120 KB |
Output is correct |
8 |
Correct |
13 ms |
21120 KB |
Output is correct |
9 |
Correct |
55 ms |
22064 KB |
Output is correct |
10 |
Correct |
10 ms |
16512 KB |
Output is correct |
11 |
Correct |
10 ms |
16512 KB |
Output is correct |
12 |
Correct |
96 ms |
18040 KB |
Output is correct |
13 |
Correct |
10 ms |
16512 KB |
Output is correct |
14 |
Correct |
10 ms |
16512 KB |
Output is correct |
15 |
Correct |
2492 ms |
173288 KB |
Output is correct |
16 |
Correct |
7664 ms |
176140 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
512 KB |
Output is correct |
21 |
Correct |
1 ms |
512 KB |
Output is correct |
22 |
Correct |
1 ms |
512 KB |
Output is correct |
23 |
Correct |
1 ms |
512 KB |
Output is correct |
24 |
Correct |
1 ms |
512 KB |
Output is correct |
25 |
Correct |
1 ms |
512 KB |
Output is correct |
26 |
Correct |
1 ms |
512 KB |
Output is correct |
27 |
Correct |
93 ms |
2936 KB |
Output is correct |
28 |
Correct |
1 ms |
512 KB |
Output is correct |
29 |
Correct |
960 ms |
2504 KB |
Output is correct |
30 |
Correct |
2043 ms |
102544 KB |
Output is correct |
31 |
Correct |
7596 ms |
181756 KB |
Output is correct |
32 |
Correct |
7370 ms |
182000 KB |
Output is correct |
33 |
Correct |
1831 ms |
84392 KB |
Output is correct |
34 |
Correct |
7263 ms |
149452 KB |
Output is correct |
35 |
Correct |
1867 ms |
84488 KB |
Output is correct |
36 |
Correct |
7257 ms |
149972 KB |
Output is correct |
37 |
Correct |
1973 ms |
104140 KB |
Output is correct |
38 |
Correct |
7208 ms |
182616 KB |
Output is correct |
39 |
Correct |
1 ms |
384 KB |
Output is correct |
40 |
Correct |
7285 ms |
150156 KB |
Output is correct |