#include <bits/stdc++.h>
#include "wombats.h"
using ll =long long;
//#define int ll
ll LINF=1000000000000000000;
int INF=1000000000;
#define pi pair<int,int>
#define pl pair<ll,ll>
#define endl '\n'
#define vi vector<int>
#define vii vector<vector<int>>
#define vl vector<ll>
#define vll vector<vector<ll>>
using namespace std;
vii h;
vii v;
int r,c;
vector<vii>dp;
void update(){
for(int end=0;end<c;end++){
auto &DP=dp[end];
int x=0;
for(int i=end;i<c-1;i++){
x+=h[r-1][i];
DP[r-1][i+1]=x;
}
x=0;
for(int i=end-1;i>=0;i--){
x+=h[r-1][i];
DP[r-1][i]+=x;
}
for(int i=r-2;i;i--){
for(int j=0;j<c;j++){
DP[i][j]=DP[i+1][j]+v[i][j];
}
for(int j=1;j<c;j++){
DP[i][j]=min(DP[i][j],DP[i-1][j]+h[i-1][j]);
}
for(int j=c-2;j;j++){
DP[i][j]=min(DP[i][j],DP[i+1][j]+h[i][j]);
}
}
}
}
void init(int R,int C,int H[5000][200],int V[5000][200]){
r=R;c=C;
h.resize(R,vi(C-1));
v.resize(C,vi(R-1));
for(int i=0;i<R;i++){
for(int j=0;j<C-1;j++)h[i][j]=H[i][j];
}
for(int i=0;i<C;i++)for(int j=0;j<R-1;j++)v[i][j]=V[i][j];
dp.resize(C,vii(R,vi(C)));
}
void changeV(int P, int Q, int W){
v[P][Q]=W;
update();
}
void changeH(int P, int Q, int W){
h[P][Q]=W;
update();
}
int escape(int x,int y){
return dp[y][0][x];
}
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 |
Runtime error |
6 ms |
9684 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
9780 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
15 ms |
18544 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
8 ms |
9792 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
13 ms |
9756 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |