///~~~LOTA~~~///
//#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ff first
#define ss second
#define ll long long
#define append push_back
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define N 10000000
int n,m;
int x[5000][100];
int y[5000][100];
int dp[5000][100][100];
void compute_dp(){
for(int i=0;i<m;i++)
for(int j=0;j<m;j++)
dp[n-1][i][j]=abs(x[n-1][i]-x[n-1][j]);
for(int i=n-2;i>=0;i--){
for(int j=0;j<m;j++){
for(int k=0;k<m;k++){
dp[i][j][k]=1e9;
for(int l=0;l<m;l++)
dp[i][j][k]=min(dp[i][j][k],
dp[i+1][l][k]+abs(x[i][j]-x[i][l])+y[i][l]);
}
}
}
}
void init(int R, int C, int H[5000][200], int V[5000][200]){
n=R; m=C;
for(int i=0;i<n;i++)
for(int j=0;j<m-1;j++)
x[i][j+1]=x[i][j]+H[i][j];
for(int i=0;i<n-1;i++)
for(int j=0;j<m;j++)
y[i][j]=V[i][j];
compute_dp();
}
void changeV(int p,int q,int w){
y[p][q]=w;
compute_dp();
}
void changeH(int p,int q,int w){
for(int i=m-1;i>q;i--)
x[p][i]-=x[p][i-1];
x[p][q+1]=w;
for(int i=q;i<m-1;i++)
x[p][q+1]+=x[p][q];
compute_dp();
}
int escape(int p,int q){
return dp[0][p][q];
}
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/cc2ckL5w.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