#include <bits/stdc++.h>
#include "wombats.h"
using namespace std;
typedef long long int;
const int MAXN = 5000;
const int MAXM = 100;
const int INF = 4e18 + 10;
int n,m;
int hor[MAXN][MAXM];
int ver[MAXN][MAXM];
int dp[MAXN][MAXM][MAXM];
int ans_m1;
void init_dp(int src)
{
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
{
dp[i][j][src] = INF;
}
}
dp[0][src][src] = 0;
for(int j = 1; j < m; j++)
{
dp[0][j][src] = min(dp[0][j][src], dp[0][j - 1][src] + hor[0][j - 1]);
}
for(int j = m - 2; j >= 0; j--)
{
dp[0][j][src] = min(dp[0][j][src], dp[0][j + 1][src] + hor[0][j]);
}
}
void fiint_dp(int src)
{
init_dp(src);
for(int i = 1; i < n; i++)
{
for(int j = 0; j < m; j++)
{
dp[i][j][src] = min(dp[i][j][src], dp[i - 1][j][src] + ver[i - 1][j]);
}
for(int j = 1; j < m; j++)
{
dp[i][j][src] = min(dp[i][j][src], dp[i][j - 1][src] + hor[i][j - 1]);
}
for(int j = m - 2; j >= 0; j--)
{
dp[i][j][src] = min(dp[i][j][src], dp[i][j + 1][src] + hor[i][j]);
}
}
}
void calc()
{
for(int src = 0; src < m; src++)
{
fiint_dp(src);
}
}
void init(int R, int C, int H[5000][200], int V[5000][200])
{
n = R;
m = C;
ans_m1 = 0;
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m - 1; j++)
{
hor[i][j] = H[i][j];
}
}
for(int i = 0; i < n - 1; i++)
{
for(int j = 0; j < m; j++)
{
ver[i][j] = V[i][j];
}
}
if(m == 1)
{
for(int i = 0; i < n; i++)
{
ans_m1 += ver[i][0];
}
}
calc();
}
void changeH(int i, int j, int w) /// change path from x;y to x;y + 1
{
hor[i][j] = w;
calc();
}
void changeV(int i, int j, int w) /// change path from x;y to x + 1;y
{
if(m == 1)
{
ans_m1 += (w - ver[i][j]);
ver[i][j] = w;
return;
}
ver[i][j] = w;
calc();
}
int escape(int from, int to) /// escape from (0;V1) to (N-1;V2)
{
if(m == 1)
return ans_m1;
return dp[n - 1][to][from];
}
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;
| ^~~
wombats.cpp:5:19: error: declaration does not declare anything [-fpermissive]
5 | typedef long long int;
| ^~~
wombats.cpp:9:22: warning: overflow in conversion from 'double' to 'int' changes value from '4.0e+18' to '2147483647' [-Woverflow]
9 | const int INF = 4e18 + 10;
| ~~~~~^~~~