#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
int n,c,x;
int h[5000][200],v[5000][200];
int dp[2][200][200];
void calc(){
for(int i=0;i<c;i++){
for(int j=0;j<c;j++){
dp[0][i][j]=2e9;
}
dp[0][i][i]=0;
}
if(1<c){
for(int i=1;i<c;i++){
for(int j=0;j<i;j++){
dp[0][i][j]=min(dp[0][i][j],dp[0][i-1][j]+h[n-1][i-1]);
}
}
for(int i=c-2;0<=i;i--){
for(int j=c-1;i<j;j--){
dp[0][i][j]=min(dp[0][i][j],dp[0][i+1][j]+h[n-1][i]);
}
}
}
x=0;
for(int i=n-2;0<=i;i--){
x=!x;
for(int j=0;j<c;j++){
for(int k=0;k<c;k++){
dp[x][j][k]=dp[!x][j][k]+v[i][j];
}
}
if(1<c){
for(int j=1;j<c;j++){
for(int k=0;k<c;k++){
dp[x][j][k]=min(dp[x][j][k],dp[x][j-1][k]+h[i][j-1]);
}
}
for(int j=c-2;0<=j;j--){
for(int k=0;k<c;k++){
dp[x][j][k]=min(dp[x][j][k],dp[x][j+1][k]+h[i][j]);
}
}
}
}
}
void init(int R, int C, int H[5000][200], int V[5000][200]) {
n=R;
c=C;
for(int i=0;i<n;i++){
for(int j=0;j<c;j++){
h[i][j]=H[i][j];
v[i][j]=V[i][j];
}
}
calc();
}
void changeH(int P, int Q, int W) {
h[P][Q]=W;
calc();
}
void changeV(int P, int Q, int W) {
v[P][Q]=W;
calc();
}
int escape(int V1, int V2) {
return dp[x][V1][V2];
}
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;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
12124 KB |
Output is correct |
2 |
Correct |
10 ms |
12124 KB |
Output is correct |
3 |
Correct |
62 ms |
14792 KB |
Output is correct |
4 |
Correct |
13 ms |
12124 KB |
Output is correct |
5 |
Correct |
10 ms |
12124 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
39 ms |
2884 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
181 ms |
988 KB |
Output is correct |
2 |
Correct |
184 ms |
988 KB |
Output is correct |
3 |
Correct |
183 ms |
856 KB |
Output is correct |
4 |
Correct |
182 ms |
996 KB |
Output is correct |
5 |
Correct |
189 ms |
856 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
881 ms |
1012 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
38 ms |
16172 KB |
Output is correct |
2 |
Correct |
41 ms |
15964 KB |
Output is correct |
3 |
Correct |
38 ms |
15960 KB |
Output is correct |
4 |
Correct |
60 ms |
17488 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
182 ms |
996 KB |
Output is correct |
2 |
Correct |
178 ms |
856 KB |
Output is correct |
3 |
Correct |
179 ms |
1112 KB |
Output is correct |
4 |
Correct |
185 ms |
860 KB |
Output is correct |
5 |
Correct |
183 ms |
820 KB |
Output is correct |
6 |
Correct |
39 ms |
15964 KB |
Output is correct |
7 |
Correct |
38 ms |
15964 KB |
Output is correct |
8 |
Correct |
38 ms |
15964 KB |
Output is correct |
9 |
Correct |
59 ms |
17492 KB |
Output is correct |
10 |
Correct |
11 ms |
12120 KB |
Output is correct |
11 |
Correct |
17 ms |
12124 KB |
Output is correct |
12 |
Correct |
48 ms |
14744 KB |
Output is correct |
13 |
Correct |
10 ms |
12236 KB |
Output is correct |
14 |
Correct |
10 ms |
12124 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
448 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
39 ms |
2756 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
885 ms |
996 KB |
Output is correct |
28 |
Execution timed out |
20098 ms |
20100 KB |
Time limit exceeded |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
176 ms |
860 KB |
Output is correct |
2 |
Correct |
160 ms |
984 KB |
Output is correct |
3 |
Correct |
167 ms |
856 KB |
Output is correct |
4 |
Correct |
159 ms |
860 KB |
Output is correct |
5 |
Correct |
164 ms |
860 KB |
Output is correct |
6 |
Correct |
34 ms |
15960 KB |
Output is correct |
7 |
Correct |
32 ms |
16156 KB |
Output is correct |
8 |
Correct |
36 ms |
16180 KB |
Output is correct |
9 |
Correct |
59 ms |
17488 KB |
Output is correct |
10 |
Correct |
9 ms |
12124 KB |
Output is correct |
11 |
Correct |
9 ms |
12236 KB |
Output is correct |
12 |
Correct |
45 ms |
14932 KB |
Output is correct |
13 |
Correct |
10 ms |
12124 KB |
Output is correct |
14 |
Correct |
12 ms |
12224 KB |
Output is correct |
15 |
Correct |
1661 ms |
25940 KB |
Output is correct |
16 |
Execution timed out |
20040 ms |
24476 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |