#include <bits/stdc++.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;
| ^~~
/usr/bin/ld: /tmp/ccj1XgE9.o: in function `main':
grader.c:(.text.startup+0x129): undefined reference to `init'
/usr/bin/ld: grader.c:(.text.startup+0x194): undefined reference to `escape'
/usr/bin/ld: grader.c:(.text.startup+0x203): undefined reference to `changeH'
/usr/bin/ld: grader.c:(.text.startup+0x26d): undefined reference to `changeV'
collect2: error: ld returned 1 exit status