이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "wombats.h"
#include <string.h>
#define N 5000
#define M 100
int min(int a, int b) { return a < b ? a : b; }
int aa[N][M - 1], bb[N - 1][M], dp[M][M], n, m;
void solve() {
int i, j, js;
for (js = 0; js < m; js++) {
int *dp_ = dp[js];
dp_[js] = 0;
for (j = js + 1; j < m; j++)
dp_[j] = dp_[j - 1] + aa[0][j - 1];
for (j = js - 1; j >= 0; j--)
dp_[j] = dp_[j + 1] + aa[0][j];
for (i = 1; i < n; i++) {
for (j = 0; j < m; j++)
dp_[j] += bb[i - 1][j];
for (j = 1; j < m; j++)
dp_[j] = min(dp_[j], dp_[j - 1] + aa[i][j - 1]);
for (j = m - 2; j >= 0; j--)
dp_[j] = min(dp_[j], dp_[j + 1] + aa[i][j]);
}
}
}
void init(int n_, int m_, int A[5000][200], int B[5000][200]) {
int i;
n = n_, m = m_;
for (i = 0; i < n; i++)
memcpy(aa[i], A[i], (m - 1) * sizeof *A[i]);
for (i = 0; i < n - 1; i++)
memcpy(bb[i], B[i], m * sizeof *B[i]);
solve();
}
void changeH(int i, int j, int w) {
aa[i][j] = w;
solve();
}
void changeV(int i, int j, int w) {
bb[i][j] = w;
solve();
}
int escape(int js, int jt) {
return dp[js][jt];
}
컴파일 시 표준 에러 (stderr) 메시지
grader.c: In function '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... |