#include "wombats.h"
#include<bits/stdc++.h>
using namespace std;
int h[5000][200];
int v[5000][200];
int r, c;
int dp[21][5001][21];
#define MOD 1000000007
int ph[5000][200];
int hdist(int y, int x1, int x2){
return abs(ph[y][x2]-ph[y][x1]);
}
void solve(int start){
for(int i=0;i<r;i++){
for(int j=0;j<c;j++){
ph[i][j+1] = ph[i][j] + h[i][j];
}
}
for(int i=0;i<c;i++) dp[start][0][i] = hdist(0, start, i);
//for(int i=0;i<c;i++) cout<<dp[start][0][i]<<" ";
//cout<<endl;
for(int layer=1;layer<r;layer++){
for(int prev=0;prev<c;prev++){
dp[start][layer][prev] = MOD;
for(int trans=0;trans<c;trans++){
dp[start][layer][prev] = min(dp[start][layer][prev], dp[start][layer-1][trans] + v[layer-1][trans] + hdist(layer, trans, prev));
}
//cout<<dp[start][layer][prev]<<" ";
}
//cout<<endl;
}
}
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];
}
}
}
void changeH(int P, int Q, int W) {
/* ... */
h[P][Q] = W;
}
void changeV(int P, int Q, int W) {
// a[P] = W;
v[P][Q] = W;
}
int escape(int V1, int V2) {
solve(V1);
return dp[V1][r-1][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;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
16384 KB |
Output is correct |
2 |
Correct |
45 ms |
16504 KB |
Output is correct |
3 |
Correct |
13048 ms |
19160 KB |
Output is correct |
4 |
Correct |
37 ms |
16340 KB |
Output is correct |
5 |
Correct |
30 ms |
16376 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
6 ms |
440 KB |
Output is correct |
5 |
Correct |
5 ms |
468 KB |
Output is correct |
6 |
Correct |
5 ms |
468 KB |
Output is correct |
7 |
Correct |
6 ms |
440 KB |
Output is correct |
8 |
Correct |
7 ms |
468 KB |
Output is correct |
9 |
Correct |
7 ms |
468 KB |
Output is correct |
10 |
Correct |
5 ms |
468 KB |
Output is correct |
11 |
Correct |
2526 ms |
2888 KB |
Output is correct |
12 |
Correct |
5 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
8 ms |
1368 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
126 ms |
20756 KB |
Output is correct |
2 |
Correct |
83 ms |
20748 KB |
Output is correct |
3 |
Correct |
123 ms |
20764 KB |
Output is correct |
4 |
Correct |
9724 ms |
22140 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
10 ms |
1388 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
7 ms |
1336 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |