이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
long long dp[205][2][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;
int bas = 1;
for(int j = 0; j < r; j++){
if(!bas){
for(int k = 0; k < c; k++){
dp[i][j&1][k] = dp[i][j&1^1][k] + v[j - 1][k];
}
}
bas = 0;
for(int k = 1; k < c; k++){
dp[i][j&1][k] = min(dp[i][j&1][k], dp[i][j&1][k - 1] + h[j][k - 1]);
}
for(int k = c - 2; k >= 0; k--){
dp[i][j&1][k] = min(dp[i][j&1][k], dp[i][j&1][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 - 1) v[i][j] = V[i][j];
if(j != C - 1) 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)%2][V2];
}
컴파일 시 표준 에러 (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;
| ^~~
wombats.cpp: In function 'void clc()':
wombats.cpp:15:44: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
15 | dp[i][j&1][k] = dp[i][j&1^1][k] + v[j - 1][k];
| ~^~
# | 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... |