#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
const int nx=5e3+5, cx=1e2+5;
int r, c, ver[nx][cx], qs[nx][cx], dp[nx][cx];
int dist(int row, int a, int b)
{
if (b>=a) return ver[row][a]+qs[row][b]-qs[row][a];
else return ver[row][a]+qs[row][a]-qs[row][b];
}
struct segtree
{
struct matrix
{
int mat[cx][cx];
void build(int row)
{
for (int i=0; i<c; i++) for (int j=0; j<c; j++) mat[i][j]=dist(row, j, i);
}
} d[3*nx];
void merge(int l, int r, int idx)
{
for (int i=0; i<c; i++) for (int j=0; j<c; j++) d[idx].mat[i][j]=1e9;
for (int i=0; i<c; i++) for (int j=0; j<c; j++) for (int k=0; k<c; k++) d[idx].mat[i][j]=min(d[idx].mat[i][j], d[2*idx+1].mat[i][k]+d[2*idx].mat[k][j]);
}
void build(int l, int r, int i)
{
if (l==r) return d[i].build(l), void();
int md=(l+r)/2;
build(l, md, 2*i);
build(md+1, r, 2*i+1);
merge(l, r, i);
}
void update(int l, int r, int i, int idx)
{
if (idx<l||r<idx) return;
if (l==r) return d[i].build(idx), void();
int md=(l+r)/2;
update(l, md, 2*i, idx);
update(md+1, r, 2*i+1, idx);
merge(l, r, i);
}
} s;
void init(int R, int C, int H[5000][200], int V[5000][200]) {
r=R, c=C;
for (int i=0; i<R-1; i++) for (int j=0; j<C; j++) ver[i+1][j]=V[i][j];
for (int i=0; i<R; i++) for (int j=0; j<C-1; j++) qs[i][j+1]=H[i][j]+qs[i][j];
s.build(1, r-1, 1);
}
void changeH(int P, int Q, int W) {
int lst=qs[P][Q+1]-qs[P][Q];
int delta=W-lst;
for (int i=Q+1; i<c; i++) qs[P][i]+=delta;
if (P>0) s.update(1, r-1, 1, P);
}
void changeV(int P, int Q, int W) {
ver[P+1][Q]=W;
s.update(1, r-1, 1, P+1);
}
int escape(int V1, int V2) {
vector<int> tmp;
int res=1e9;
for (int i=0; i<c; i++) res=min(res, s.d[1].mat[V2][i]+dist(0, V1, i));
return res;
}
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;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
103 ms |
134996 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
8540 KB |
Output is correct |
5 |
Correct |
1 ms |
8540 KB |
Output is correct |
6 |
Correct |
1 ms |
8540 KB |
Output is correct |
7 |
Correct |
2 ms |
8536 KB |
Output is correct |
8 |
Correct |
1 ms |
8540 KB |
Output is correct |
9 |
Correct |
2 ms |
8536 KB |
Output is correct |
10 |
Correct |
1 ms |
8540 KB |
Output is correct |
11 |
Correct |
59 ms |
9488 KB |
Output is correct |
12 |
Correct |
1 ms |
8536 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
568 ms |
19016 KB |
Output is correct |
2 |
Correct |
562 ms |
18772 KB |
Output is correct |
3 |
Correct |
568 ms |
19016 KB |
Output is correct |
4 |
Correct |
583 ms |
19252 KB |
Output is correct |
5 |
Correct |
535 ms |
18772 KB |
Output is correct |
6 |
Correct |
1 ms |
4440 KB |
Output is correct |
7 |
Correct |
1 ms |
4440 KB |
Output is correct |
8 |
Correct |
0 ms |
4444 KB |
Output is correct |
9 |
Correct |
2460 ms |
19016 KB |
Output is correct |
10 |
Correct |
1 ms |
6488 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
105 ms |
119888 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
607 ms |
19024 KB |
Output is correct |
2 |
Correct |
556 ms |
18772 KB |
Output is correct |
3 |
Correct |
762 ms |
19012 KB |
Output is correct |
4 |
Correct |
581 ms |
19256 KB |
Output is correct |
5 |
Correct |
606 ms |
18772 KB |
Output is correct |
6 |
Runtime error |
131 ms |
143444 KB |
Execution killed with signal 11 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
580 ms |
19256 KB |
Output is correct |
2 |
Correct |
582 ms |
18768 KB |
Output is correct |
3 |
Correct |
605 ms |
19012 KB |
Output is correct |
4 |
Correct |
612 ms |
18772 KB |
Output is correct |
5 |
Correct |
548 ms |
19012 KB |
Output is correct |
6 |
Runtime error |
138 ms |
147144 KB |
Execution killed with signal 11 |
7 |
Halted |
0 ms |
0 KB |
- |