#include <bits/stdc++.h>
#include "wombats.h"
using namespace std;
const int MAXN = 5010;
const int MAXC = 300;
const int MOD = 1e9 + 7;
int n , m , h[MAXN][MAXC] , v[MAXN][MAXC] , dp[MAXC][MAXC];
void solve(){
if(n * m * m >= int(2e6)) return;
for(int i = 0 ; i < m ; i++){
fill(dp[i] , dp[i] + MAXC , MOD);
dp[i][i] = 0;
for(int j = 0 ; j < n ; j++){
if(j) for(int k = 0 ; k < m ; k++) dp[i][k] += v[j - 1][k];
for(int k = 1 ; k < m ; k++){
dp[i][k] = min(dp[i][k] , dp[i][k - 1] + h[j][k - 1]);
}
for(int k = m - 2 ; k >= 0 ; k--){
dp[i][k] = min(dp[i][k] , dp[i][k + 1] + h[j][k]);
}
}
}
}
void init(int R, int C, int H[5000][200], int V[5000][200]) {
/* ... */
int sum = 0;
n = R; m = C;
for(int i = 0 ; i < 5000 ; i++){
for(int j = 0 ; j < 200 ; j++){
h[i][j] = H[i][j];
v[i][j] = V[i][j];
}
}
solve();
}
void changeH(int P, int Q, int W) {
h[P][Q] = W;
solve();
}
void changeV(int P, int Q, int W) {
v[P][Q] = W;
solve();
}
int escape(int V1, int V2) {
return dp[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;
| ^~~
wombats.cpp: In function 'void init(int, int, int (*)[200], int (*)[200])':
wombats.cpp:30:6: warning: unused variable 'sum' [-Wunused-variable]
30 | int sum = 0;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
25 ms |
15980 KB |
Output is correct |
2 |
Correct |
25 ms |
16108 KB |
Output is correct |
3 |
Correct |
129 ms |
17644 KB |
Output is correct |
4 |
Correct |
24 ms |
15980 KB |
Output is correct |
5 |
Correct |
25 ms |
15980 KB |
Output is correct |
6 |
Correct |
9 ms |
12140 KB |
Output is correct |
7 |
Correct |
10 ms |
12140 KB |
Output is correct |
8 |
Correct |
9 ms |
12140 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
12140 KB |
Output is correct |
2 |
Correct |
9 ms |
12140 KB |
Output is correct |
3 |
Correct |
9 ms |
12140 KB |
Output is correct |
4 |
Correct |
10 ms |
12140 KB |
Output is correct |
5 |
Correct |
10 ms |
12140 KB |
Output is correct |
6 |
Correct |
10 ms |
12140 KB |
Output is correct |
7 |
Correct |
10 ms |
12140 KB |
Output is correct |
8 |
Correct |
10 ms |
12140 KB |
Output is correct |
9 |
Correct |
10 ms |
12140 KB |
Output is correct |
10 |
Correct |
10 ms |
12140 KB |
Output is correct |
11 |
Correct |
91 ms |
14572 KB |
Output is correct |
12 |
Correct |
10 ms |
12140 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
910 ms |
12524 KB |
Output is correct |
2 |
Correct |
894 ms |
12524 KB |
Output is correct |
3 |
Correct |
918 ms |
12524 KB |
Output is correct |
4 |
Correct |
919 ms |
12524 KB |
Output is correct |
5 |
Correct |
896 ms |
12504 KB |
Output is correct |
6 |
Correct |
9 ms |
12140 KB |
Output is correct |
7 |
Correct |
9 ms |
12140 KB |
Output is correct |
8 |
Correct |
11 ms |
12140 KB |
Output is correct |
9 |
Correct |
4466 ms |
12500 KB |
Output is correct |
10 |
Correct |
9 ms |
12140 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
89 ms |
19948 KB |
Output is correct |
2 |
Correct |
87 ms |
19948 KB |
Output is correct |
3 |
Correct |
88 ms |
19948 KB |
Output is correct |
4 |
Correct |
132 ms |
20716 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
910 ms |
12548 KB |
Output is correct |
2 |
Correct |
887 ms |
12396 KB |
Output is correct |
3 |
Correct |
915 ms |
12524 KB |
Output is correct |
4 |
Correct |
915 ms |
12524 KB |
Output is correct |
5 |
Correct |
936 ms |
12524 KB |
Output is correct |
6 |
Correct |
92 ms |
20076 KB |
Output is correct |
7 |
Correct |
93 ms |
19948 KB |
Output is correct |
8 |
Correct |
90 ms |
20204 KB |
Output is correct |
9 |
Correct |
129 ms |
21356 KB |
Output is correct |
10 |
Correct |
25 ms |
15980 KB |
Output is correct |
11 |
Correct |
25 ms |
15980 KB |
Output is correct |
12 |
Correct |
112 ms |
18932 KB |
Output is correct |
13 |
Correct |
25 ms |
15980 KB |
Output is correct |
14 |
Correct |
25 ms |
15980 KB |
Output is correct |
15 |
Correct |
9 ms |
12140 KB |
Output is correct |
16 |
Correct |
9 ms |
12140 KB |
Output is correct |
17 |
Correct |
11 ms |
12140 KB |
Output is correct |
18 |
Correct |
11 ms |
12164 KB |
Output is correct |
19 |
Correct |
10 ms |
12140 KB |
Output is correct |
20 |
Correct |
10 ms |
12140 KB |
Output is correct |
21 |
Correct |
11 ms |
12140 KB |
Output is correct |
22 |
Correct |
10 ms |
12140 KB |
Output is correct |
23 |
Correct |
10 ms |
12140 KB |
Output is correct |
24 |
Correct |
10 ms |
12140 KB |
Output is correct |
25 |
Correct |
95 ms |
14632 KB |
Output is correct |
26 |
Correct |
10 ms |
12140 KB |
Output is correct |
27 |
Correct |
4552 ms |
12524 KB |
Output is correct |
28 |
Incorrect |
139 ms |
23916 KB |
Output isn't correct |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
915 ms |
12424 KB |
Output is correct |
2 |
Correct |
896 ms |
12492 KB |
Output is correct |
3 |
Correct |
930 ms |
12524 KB |
Output is correct |
4 |
Correct |
921 ms |
12504 KB |
Output is correct |
5 |
Correct |
898 ms |
12524 KB |
Output is correct |
6 |
Correct |
90 ms |
20036 KB |
Output is correct |
7 |
Correct |
89 ms |
19948 KB |
Output is correct |
8 |
Correct |
88 ms |
20076 KB |
Output is correct |
9 |
Correct |
132 ms |
21356 KB |
Output is correct |
10 |
Correct |
25 ms |
15980 KB |
Output is correct |
11 |
Correct |
25 ms |
15980 KB |
Output is correct |
12 |
Correct |
103 ms |
18796 KB |
Output is correct |
13 |
Correct |
25 ms |
15980 KB |
Output is correct |
14 |
Correct |
25 ms |
15980 KB |
Output is correct |
15 |
Incorrect |
233 ms |
29804 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |