#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
int H, W, size_, A1[5009][209], A2[5009][209], dat[5009][109][109], U[16384]; bool ok[16384];
int M[2][109][109];
void getval(int ty, int pos) {
pos += size_;
for (int i = 0; i < W; i++) {
M[ty][i][i] = A2[pos - size_][i]; int s = 0;
for (int j = i + 1; j < W; j++) {
s += A1[pos - size_][j - 1];
M[ty][i][j] = s + A2[pos - size_][j];
}
s = 0;
for (int j = i - 1; j >= 0; j--) {
s += A1[pos - size_][j];
M[ty][i][j] = s + A2[pos - size_][j];
}
}
}
void update(int pos) {
if (ok[pos * 2 + 1] == false) {
if (pos * 2 < size_) {
for (int i = 0; i < W; i++) {
for (int j = 0; j < W; j++) dat[U[pos]][i][j] = dat[U[pos * 2]][i][j];
}
}
else {
getval(0, pos * 2 - size_);
for (int i = 0; i < W; i++) {
for (int j = 0; j < W; j++) dat[U[pos]][i][j] = M[0][i][j];
}
}
return;
}
int L = pos * 2, R = pos * 2 + 1;
if (L < size_) {
for (int i = 0; i < W; i++) {
for (int j = 0; j < W; j++) {
M[0][i][j] = dat[U[L]][i][j];
M[1][i][j] = dat[U[R]][i][j];
}
}
}
else {
getval(0, L - size_);
getval(1, R - size_);
}
int rev = U[pos];
for (int i = 0; i < W; i++) { for (int j = 0; j < W; j++) dat[rev][i][j] = (1 << 30); }
for (int i = 0; i < W; i++) {
for (int j = 0; j < W; j++) {
for (int k = 0; k < W; k++) dat[rev][i][k] = min(dat[rev][i][k], M[0][i][j] + M[1][j][k]);
}
}
}
void recharge(int pos, int B){
pos += size_;
while (pos >= 2) {
if (B == 2 && pos % 2 == 0) break;
pos /= 2;
update(pos);
}
}
void init(int R, int C, int I[5000][200], int V[5000][200]) {
size_ = 1; while (size_ < R) size_ *= 2;
H = R; W = C;
for (int i = 0; i < H; i++) {
int cx = i + size_; ok[cx] = true;
while (cx >= 2) { cx /= 2; ok[cx] = true; }
}
int cntv = 0;
for (int i = 0; i < size_; i++) {
if (ok[i] == true) { U[i] = cntv; cntv++; }
}
for (int i = 0; i < H; i++) {
for(int j = 0; j < W - 1; j++) A1[i][j] = I[i][j];
}
for (int i = 0; i < H - 1; i++) {
for (int j = 0; j < W; j++) A2[i][j] = V[i][j];
}
for (int i = 0; i < size_; i++) recharge(i, 2);
/*for (int i = 0; i < cntv; i++) {
cout<<i<<":"<<endl;
for (int j = 0; j < W; j++) {
for (int k = 0; k < W; k++) cout<<dat[i][j][k]<<" "; cout<<endl;
}
cout<<endl;
}*/
}
void changeH(int P, int Q, int T) {
A1[P][Q] = T;
recharge(P, 1);
}
void changeV(int P, int Q, int T) {
A2[P][Q] = T;
recharge(P, 1);
}
int escape(int V1, int V2) {
return dat[U[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]
int res;
^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
28928 KB |
Output is correct |
2 |
Correct |
27 ms |
28800 KB |
Output is correct |
3 |
Correct |
87 ms |
30456 KB |
Output is correct |
4 |
Correct |
24 ms |
28892 KB |
Output is correct |
5 |
Correct |
23 ms |
28928 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
768 KB |
Output is correct |
5 |
Correct |
3 ms |
640 KB |
Output is correct |
6 |
Correct |
3 ms |
768 KB |
Output is correct |
7 |
Correct |
4 ms |
768 KB |
Output is correct |
8 |
Correct |
2 ms |
640 KB |
Output is correct |
9 |
Correct |
3 ms |
640 KB |
Output is correct |
10 |
Correct |
3 ms |
768 KB |
Output is correct |
11 |
Correct |
69 ms |
1656 KB |
Output is correct |
12 |
Correct |
3 ms |
640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
803 ms |
5672 KB |
Output is correct |
2 |
Correct |
748 ms |
5624 KB |
Output is correct |
3 |
Correct |
703 ms |
5496 KB |
Output is correct |
4 |
Correct |
711 ms |
5496 KB |
Output is correct |
5 |
Correct |
762 ms |
5404 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
3345 ms |
5588 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
144 ms |
77796 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
728 ms |
5552 KB |
Output is correct |
2 |
Correct |
731 ms |
5624 KB |
Output is correct |
3 |
Correct |
788 ms |
5724 KB |
Output is correct |
4 |
Correct |
819 ms |
5496 KB |
Output is correct |
5 |
Correct |
736 ms |
5496 KB |
Output is correct |
6 |
Runtime error |
147 ms |
77816 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
778 ms |
5552 KB |
Output is correct |
2 |
Correct |
771 ms |
5536 KB |
Output is correct |
3 |
Correct |
715 ms |
5624 KB |
Output is correct |
4 |
Correct |
718 ms |
5560 KB |
Output is correct |
5 |
Correct |
780 ms |
5452 KB |
Output is correct |
6 |
Runtime error |
140 ms |
77816 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Halted |
0 ms |
0 KB |
- |