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"
#include <bits/stdc++.h>
using namespace std;
int dp[205][5001][205];
int h[5000][200], v[5000][200];
int r, c;
void clc(){
memset(dp, 0x7f, sizeof(dp));
for(int i = 0; i < c; i++){
dp[i][0][i] = 0;
for(int j = 0; j < r; j++){
if(j != 0){
for(int k = 0; k < c; k++){
dp[i][j][k] = dp[i][j - 1][k] + v[j - 1][k];
}
}
for(int k = 1; k < c; k++){
dp[i][j][k] = min(dp[i][j][k], dp[i][j][k - 1] + h[j][k - 1]);
}
for(int k = c - 2; k >= 0; k--){
dp[i][j][k] = min(dp[i][j][k], dp[i][j][k + 1] + h[j][k]);
}
}
}
}
void init(int R, int C, int H[5000][200], int V[5000][200]) {
r = R;
c = C;
for(int i = 0; i < R; i++){
for(int j = 0; j < C; j++){
if(i != R) v[i][j] = V[i][j];
if(j != C) h[i][j] = H[i][j];
}
}
clc();
}
void changeH(int P, int Q, int W) {
h[P][Q] = W;
clc();
}
void changeV(int P, int Q, int W) {
v[P][Q] = W;
clc();
}
int escape(int V1, int V2) {
return dp[V1][r - 1][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... |