#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int INF = 2e9 + 100;
int (*H)[200], (*V)[200], n, m;
int sum[5000][200];
inline int dist(int x, int i, int j){
if (i<=j) return sum[x][j] - sum[x][i];
return sum[x][i] - sum[x][j];
}
struct Node{
int a[101][101];
Node(){}
void init(int x){
for (int i=0;i<m;i++){
for (int j=0;j<m;j++){
a[i][j] = INF;
for (int k=0;k<m;k++){
a[i][j] = min(a[i][j], V[x][k] + dist(x, i, k) + dist(x+1, j, k));
}
// printf("%d %d %d -> %d\n", x, i, j, a[i][j]);
}
}
}
void merge(const Node &L, const Node &R){
for (int i=0;i<m;i++){
for (int j=0;j<m;j++){
a[i][j] = INF;
for (int k=0;k<m;k++){
a[i][j] = min(a[i][j], L.a[i][k] + R.a[k][j]);
}
}
}
}
};
struct Seg{
Node tree[20020];
void init(int i, int l, int r){
if (l==r){
tree[i].init(l);
return;
}
int m = (l+r)>>1;
init(i<<1, l, m); init(i<<1|1, m+1, r);
tree[i].merge(tree[i<<1], tree[i<<1|1]);
}
void update(int i, int l, int r, int p){
if (r<p || p<l) return;
if (l==r){
tree[i].init(l);
return;
}
int m = (l+r)>>1;
update(i<<1, l, m, p); update(i<<1|1, m+1, r, p);
tree[i].merge(tree[i<<1], tree[i<<1|1]);
}
}tree;
void initH(int x){
for (int i=1;i<m;i++) sum[x][i] = sum[x][i-1] + H[x][i-1];
}
void init(int R, int C, int h[5000][200], int v[5000][200]) {
n = R, m = C;
H = h, V = v;
for (int i=0;i<R;i++) initH(i);
tree.init(1, 0, n-2);
}
void changeH(int P, int Q, int W) {
H[P][Q] = W;
initH(P);
tree.update(1, 0, n-2, P-1);
tree.update(1, 0, n-2, P);
}
void changeV(int P, int Q, int W) {
V[P][Q] = W;
tree.update(1, 0, n-2, P);
}
int escape(int V1, int V2) {
return tree.tree[1].a[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 |
19 ms |
45504 KB |
Output is correct |
2 |
Correct |
19 ms |
45452 KB |
Output is correct |
3 |
Correct |
76 ms |
48256 KB |
Output is correct |
4 |
Correct |
19 ms |
45388 KB |
Output is correct |
5 |
Correct |
19 ms |
45396 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
724 KB |
Output is correct |
5 |
Correct |
1 ms |
692 KB |
Output is correct |
6 |
Correct |
1 ms |
692 KB |
Output is correct |
7 |
Correct |
1 ms |
724 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
1 ms |
696 KB |
Output is correct |
10 |
Correct |
1 ms |
724 KB |
Output is correct |
11 |
Correct |
61 ms |
3328 KB |
Output is correct |
12 |
Correct |
1 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1565 ms |
8560 KB |
Output is correct |
2 |
Correct |
1124 ms |
8492 KB |
Output is correct |
3 |
Correct |
1958 ms |
8624 KB |
Output is correct |
4 |
Correct |
1143 ms |
8512 KB |
Output is correct |
5 |
Correct |
1516 ms |
8652 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
304 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
7627 ms |
8592 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
57224 KB |
Output is correct |
2 |
Correct |
22 ms |
57300 KB |
Output is correct |
3 |
Correct |
24 ms |
57228 KB |
Output is correct |
4 |
Correct |
51 ms |
58636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1582 ms |
8552 KB |
Output is correct |
2 |
Correct |
1122 ms |
8496 KB |
Output is correct |
3 |
Correct |
1973 ms |
8592 KB |
Output is correct |
4 |
Correct |
1139 ms |
8652 KB |
Output is correct |
5 |
Correct |
1510 ms |
8524 KB |
Output is correct |
6 |
Correct |
27 ms |
57308 KB |
Output is correct |
7 |
Correct |
24 ms |
57256 KB |
Output is correct |
8 |
Correct |
22 ms |
57212 KB |
Output is correct |
9 |
Correct |
51 ms |
58680 KB |
Output is correct |
10 |
Correct |
18 ms |
45396 KB |
Output is correct |
11 |
Correct |
17 ms |
45436 KB |
Output is correct |
12 |
Correct |
76 ms |
48220 KB |
Output is correct |
13 |
Correct |
20 ms |
45524 KB |
Output is correct |
14 |
Correct |
19 ms |
45444 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
312 KB |
Output is correct |
18 |
Correct |
1 ms |
724 KB |
Output is correct |
19 |
Correct |
1 ms |
696 KB |
Output is correct |
20 |
Correct |
1 ms |
696 KB |
Output is correct |
21 |
Correct |
1 ms |
696 KB |
Output is correct |
22 |
Correct |
1 ms |
724 KB |
Output is correct |
23 |
Correct |
1 ms |
696 KB |
Output is correct |
24 |
Correct |
1 ms |
724 KB |
Output is correct |
25 |
Correct |
56 ms |
3092 KB |
Output is correct |
26 |
Correct |
1 ms |
724 KB |
Output is correct |
27 |
Correct |
7625 ms |
8588 KB |
Output is correct |
28 |
Runtime error |
9203 ms |
262144 KB |
Execution killed with signal 9 |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1568 ms |
8572 KB |
Output is correct |
2 |
Correct |
1112 ms |
8492 KB |
Output is correct |
3 |
Correct |
1971 ms |
8596 KB |
Output is correct |
4 |
Correct |
1146 ms |
8592 KB |
Output is correct |
5 |
Correct |
1504 ms |
8576 KB |
Output is correct |
6 |
Correct |
22 ms |
57276 KB |
Output is correct |
7 |
Correct |
24 ms |
57280 KB |
Output is correct |
8 |
Correct |
23 ms |
57252 KB |
Output is correct |
9 |
Correct |
51 ms |
58644 KB |
Output is correct |
10 |
Correct |
18 ms |
45424 KB |
Output is correct |
11 |
Correct |
17 ms |
45396 KB |
Output is correct |
12 |
Correct |
73 ms |
48224 KB |
Output is correct |
13 |
Correct |
25 ms |
45516 KB |
Output is correct |
14 |
Correct |
19 ms |
45500 KB |
Output is correct |
15 |
Execution timed out |
20105 ms |
94560 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |