#include"wombats.h"
#ifndef EVAL
#include"grader.c"
#endif
#include<bits/stdc++.h>
using namespace std;
int h[200][5000],v[200][5000],dp[200];
int n,m;
void init(int R,int C,int H[5000][200],int V[5000][200]){
n=R,m=C;
for(int y=0;y<n;y++)
for(int x=0;x+1<m;x++)h[x][y]=H[y][x];
for(int x=0;x<m;x++)
for(int y=0;y+1<n;y++)v[x][y]=V[y][x];
}
void changeH(int P,int Q,int W){
h[Q][P]=W;
}
void changeV(int P,int Q,int W){
v[Q][P]=W;
}
int escape(int V1,int V2){
for(int x=0;x<m;x++)dp[x]=2e9;
dp[V1]=0;
for(int x=0;x+1<m;x++)dp[x+1]=min(dp[x+1],dp[x]+v[x][0]);
for(int x=m-1;x>0;x--)dp[x-1]=min(dp[x-1],dp[x]+v[x-1][0]);
for(int y=0;y+1<n;y++){
for(int x=0;x<m;x++)dp[x]+=v[x][y];
for(int x=0;x+1<m;x++)dp[x+1]=min(dp[x+1],dp[x]+v[x][y+1]);
for(int x=m-1;x>0;x--)dp[x-1]=min(dp[x-1],dp[x]+v[x-1][y+1]);
}
return dp[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 |
10 ms |
4204 KB |
Output is correct |
2 |
Correct |
10 ms |
4204 KB |
Output is correct |
3 |
Correct |
2779 ms |
5976 KB |
Output is correct |
4 |
Correct |
11 ms |
4204 KB |
Output is correct |
5 |
Correct |
10 ms |
4204 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
0 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Incorrect |
2 ms |
492 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
1388 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
61 ms |
8280 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
1408 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
1388 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |