#include <bits/stdc++.h>
#include "wombats.h"
using namespace std;
vector<vector<vector<vector<int>>>> dp;
int n,m,h[5000][200],v[5000][200];
int ans(int r , int c , int en , int tag){
if(r == n-1 && c == en){
return 0;
}
if(dp[r][c][en][tag] != -1){
return dp[r][c][en][tag];
}
int ret = 1000000000;
if(!tag){
if(c){
ret = min(ret,h[r][c-1]+ans(r,c-1,en,tag));
}
}else{
if(c+1 < m){
ret = min(ret,h[r][c]+ans(r,c+1,en,tag));
}
}
if(r+1 < n){
ret = min(ret,v[r][c]+min(ans(r+1,c,en,0),ans(r+1,c,en,1)));
}
return dp[r][c][en][tag] = ret;
}
void re(){
dp.assign(n+1,vector<vector<vector<int>>>(m+1,vector<vector<int>>(m+1,vector<int>(2,-1))));
}
void init(int R , int C , int H[5000][200] , int V[5000][200]){
n = R , m = C;
dp.assign(n+1,vector<vector<vector<int>>>(m+1,vector<vector<int>>(m+1,vector<int>(2,-1))));
for(int i = 0 ; i < n ; i += 1){
for(int j = 0 ; j < m ; j += 1){
h[i][j] = H[i][j] , v[i][j] = V[i][j];
}
}
re();
}
void changeH(int P , int Q , int W){
h[P][Q] = W;
re();
}
void changeV(int P , int Q , int W){
v[P][Q] = W;
re();
}
int escape(int V1 , int V2){
return min(ans(0,V1,V2,0),ans(0,V1,V2,1));
}
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 |
263 ms |
14156 KB |
Output is correct |
2 |
Correct |
266 ms |
14204 KB |
Output is correct |
3 |
Correct |
356 ms |
17092 KB |
Output is correct |
4 |
Correct |
261 ms |
14208 KB |
Output is correct |
5 |
Correct |
263 ms |
14212 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
844 KB |
Output is correct |
5 |
Correct |
3 ms |
844 KB |
Output is correct |
6 |
Correct |
3 ms |
844 KB |
Output is correct |
7 |
Correct |
3 ms |
844 KB |
Output is correct |
8 |
Correct |
2 ms |
844 KB |
Output is correct |
9 |
Correct |
2 ms |
844 KB |
Output is correct |
10 |
Correct |
2 ms |
844 KB |
Output is correct |
11 |
Correct |
88 ms |
3176 KB |
Output is correct |
12 |
Correct |
3 ms |
824 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1378 ms |
57596 KB |
Output is correct |
2 |
Correct |
1376 ms |
56516 KB |
Output is correct |
3 |
Correct |
1405 ms |
58072 KB |
Output is correct |
4 |
Correct |
1393 ms |
58272 KB |
Output is correct |
5 |
Correct |
1406 ms |
57016 KB |
Output is correct |
6 |
Correct |
1 ms |
300 KB |
Output is correct |
7 |
Correct |
1 ms |
304 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
6098 ms |
58064 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
925 ms |
19580 KB |
Output is correct |
2 |
Correct |
944 ms |
19544 KB |
Output is correct |
3 |
Correct |
927 ms |
19560 KB |
Output is correct |
4 |
Correct |
992 ms |
21160 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1338 ms |
57436 KB |
Output is correct |
2 |
Correct |
1374 ms |
56516 KB |
Output is correct |
3 |
Correct |
1405 ms |
58160 KB |
Output is correct |
4 |
Correct |
1382 ms |
58140 KB |
Output is correct |
5 |
Correct |
1409 ms |
56900 KB |
Output is correct |
6 |
Correct |
948 ms |
19568 KB |
Output is correct |
7 |
Correct |
946 ms |
19652 KB |
Output is correct |
8 |
Correct |
946 ms |
19688 KB |
Output is correct |
9 |
Correct |
1010 ms |
21072 KB |
Output is correct |
10 |
Correct |
265 ms |
14196 KB |
Output is correct |
11 |
Correct |
265 ms |
14200 KB |
Output is correct |
12 |
Correct |
341 ms |
16988 KB |
Output is correct |
13 |
Correct |
271 ms |
14156 KB |
Output is correct |
14 |
Correct |
263 ms |
14136 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
3 ms |
844 KB |
Output is correct |
19 |
Correct |
3 ms |
948 KB |
Output is correct |
20 |
Correct |
2 ms |
844 KB |
Output is correct |
21 |
Correct |
2 ms |
844 KB |
Output is correct |
22 |
Correct |
2 ms |
844 KB |
Output is correct |
23 |
Correct |
2 ms |
844 KB |
Output is correct |
24 |
Correct |
3 ms |
844 KB |
Output is correct |
25 |
Correct |
84 ms |
3248 KB |
Output is correct |
26 |
Correct |
3 ms |
844 KB |
Output is correct |
27 |
Correct |
6130 ms |
58060 KB |
Output is correct |
28 |
Runtime error |
348 ms |
262148 KB |
Execution killed with signal 9 |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1380 ms |
57628 KB |
Output is correct |
2 |
Correct |
1366 ms |
56516 KB |
Output is correct |
3 |
Correct |
1417 ms |
57992 KB |
Output is correct |
4 |
Correct |
1417 ms |
58068 KB |
Output is correct |
5 |
Correct |
1417 ms |
57028 KB |
Output is correct |
6 |
Correct |
974 ms |
19552 KB |
Output is correct |
7 |
Correct |
948 ms |
19564 KB |
Output is correct |
8 |
Correct |
948 ms |
19560 KB |
Output is correct |
9 |
Correct |
994 ms |
20900 KB |
Output is correct |
10 |
Correct |
274 ms |
14192 KB |
Output is correct |
11 |
Correct |
263 ms |
14196 KB |
Output is correct |
12 |
Correct |
369 ms |
16872 KB |
Output is correct |
13 |
Correct |
264 ms |
14156 KB |
Output is correct |
14 |
Correct |
275 ms |
14200 KB |
Output is correct |
15 |
Runtime error |
451 ms |
262148 KB |
Execution killed with signal 9 |
16 |
Halted |
0 ms |
0 KB |
- |