# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
289091 |
2020-09-02T10:42:53 Z |
egekabas |
Wombats (IOI13_wombats) |
C++14 |
|
20000 ms |
17016 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 = 1668;
int h[5000][200];
int v[5000][200];
int dis[5000/sq+5][200][200];
void dijkstra(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]);
}
}
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)
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)
dijkstra(i, min(i+sq, r-1), j, dis[i/sq][j]);
}
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[5000/sq+5];
int escape(int V1, int V2) {
for(auto u : change){
if(done[u]) continue;
for(int j = 0; j < c; ++j)
dijkstra(u*sq, min(r-1, (u+1)*sq), j, dis[u][j]);
}
for(auto u : change)
done[u] = 0;
change.clear();
for(int j = 0; j < c; ++j)
curd[j] = newd[j] = 1e9+7;
curd[V1] = 0;
for(int i = 0; i < r; i += sq){
if(i + sq >= r){
for(int j = 0; j < c; ++j){
newd[V2] = min(newd[V2], curd[j]+dis[i/sq][V2][j]);
}
return newd[V2];
}
for(int j = 0; j < c; ++j)
for(int k = 0; k < c; ++k)
newd[k] = min(newd[k], curd[j]+dis[i/sq][k][j]);
for(int j = 0; j < c; ++j){
curd[j] = newd[j];
newd[j] = 1e9+7;
}
}
return curd[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 |
12 ms |
12032 KB |
Output is correct |
2 |
Correct |
11 ms |
12032 KB |
Output is correct |
3 |
Correct |
95 ms |
13688 KB |
Output is correct |
4 |
Correct |
12 ms |
12032 KB |
Output is correct |
5 |
Correct |
12 ms |
12032 KB |
Output is correct |
6 |
Correct |
0 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 |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
1 ms |
416 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
103 ms |
1400 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
957 ms |
788 KB |
Output is correct |
2 |
Correct |
939 ms |
792 KB |
Output is correct |
3 |
Correct |
962 ms |
888 KB |
Output is correct |
4 |
Correct |
958 ms |
920 KB |
Output is correct |
5 |
Correct |
929 ms |
888 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
4590 ms |
888 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
16040 KB |
Output is correct |
2 |
Correct |
32 ms |
16000 KB |
Output is correct |
3 |
Correct |
33 ms |
16048 KB |
Output is correct |
4 |
Correct |
76 ms |
16760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
953 ms |
912 KB |
Output is correct |
2 |
Correct |
933 ms |
896 KB |
Output is correct |
3 |
Correct |
961 ms |
888 KB |
Output is correct |
4 |
Correct |
962 ms |
888 KB |
Output is correct |
5 |
Correct |
932 ms |
768 KB |
Output is correct |
6 |
Correct |
33 ms |
16000 KB |
Output is correct |
7 |
Correct |
32 ms |
16000 KB |
Output is correct |
8 |
Correct |
33 ms |
16000 KB |
Output is correct |
9 |
Correct |
79 ms |
17016 KB |
Output is correct |
10 |
Correct |
12 ms |
12032 KB |
Output is correct |
11 |
Correct |
12 ms |
12032 KB |
Output is correct |
12 |
Correct |
98 ms |
13756 KB |
Output is correct |
13 |
Correct |
14 ms |
12032 KB |
Output is correct |
14 |
Correct |
12 ms |
12032 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 |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
1 ms |
384 KB |
Output is correct |
25 |
Correct |
98 ms |
1584 KB |
Output is correct |
26 |
Correct |
1 ms |
384 KB |
Output is correct |
27 |
Correct |
4583 ms |
892 KB |
Output is correct |
28 |
Execution timed out |
20090 ms |
16536 KB |
Time limit exceeded |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
955 ms |
1016 KB |
Output is correct |
2 |
Correct |
937 ms |
888 KB |
Output is correct |
3 |
Correct |
965 ms |
888 KB |
Output is correct |
4 |
Correct |
959 ms |
792 KB |
Output is correct |
5 |
Correct |
934 ms |
768 KB |
Output is correct |
6 |
Correct |
33 ms |
16000 KB |
Output is correct |
7 |
Correct |
33 ms |
16000 KB |
Output is correct |
8 |
Correct |
34 ms |
16000 KB |
Output is correct |
9 |
Correct |
78 ms |
16872 KB |
Output is correct |
10 |
Correct |
11 ms |
12032 KB |
Output is correct |
11 |
Correct |
12 ms |
12032 KB |
Output is correct |
12 |
Correct |
106 ms |
13704 KB |
Output is correct |
13 |
Correct |
12 ms |
12032 KB |
Output is correct |
14 |
Correct |
12 ms |
12160 KB |
Output is correct |
15 |
Correct |
4878 ms |
16504 KB |
Output is correct |
16 |
Execution timed out |
20074 ms |
16764 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |