This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |