#include "wombats.h"
#include<bits/stdc++.h>
using namespace std;
int ans[200][200],lr[5000][200],dn[5000][200],col,row;
void init(int R, int C, int H[5000][200], int V[5000][200]) {
memcpy(lr,H,sizeof lr);
memcpy(dn,V,sizeof dn);
memset(ans,-1,sizeof ans);
row=R;
col=C;
}
void changeH(int P, int Q, int W) {
memset(ans,-1,sizeof ans);
lr[P][Q]=W;
}
void changeV(int P, int Q, int W) {
memset(ans,-1,sizeof ans);
dn[P][Q]=W;
}
void calcstuff(int strt){
int dp[200];
memset(dp,7,sizeof dp);
dp[strt]=0;
for(int i=strt;i--;)
dp[i]=dp[i+1]+lr[0][i];
for(int i=strt;++i<col;)
dp[i]=dp[i-1]+lr[0][i-1];
for(int i=1;i<row;i++){
for(int j=0;j<col;j++)
dp[j]+=dn[i-1][j];
for(int j=col;--j;)
dp[j-1]=min(dp[j-1],dp[j]+lr[i][j-1]);
for(int j=0;++j<col;)
dp[j]=min(dp[j],dp[j-1]+lr[i][j-1]);
}
memcpy(ans[strt],dp,sizeof dp);
}
int escape(int V1, int V2) {
if(ans[V1][V2]<0)
calcstuff(V1);
return ans[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 |
11 ms |
12124 KB |
Output is correct |
2 |
Correct |
10 ms |
12380 KB |
Output is correct |
3 |
Correct |
46 ms |
14900 KB |
Output is correct |
4 |
Correct |
10 ms |
12376 KB |
Output is correct |
5 |
Correct |
10 ms |
12376 KB |
Output is correct |
6 |
Correct |
3 ms |
8284 KB |
Output is correct |
7 |
Correct |
3 ms |
8284 KB |
Output is correct |
8 |
Correct |
3 ms |
8284 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
8284 KB |
Output is correct |
2 |
Correct |
3 ms |
8284 KB |
Output is correct |
3 |
Correct |
3 ms |
8284 KB |
Output is correct |
4 |
Correct |
4 ms |
10332 KB |
Output is correct |
5 |
Correct |
4 ms |
10460 KB |
Output is correct |
6 |
Correct |
4 ms |
10332 KB |
Output is correct |
7 |
Correct |
4 ms |
10332 KB |
Output is correct |
8 |
Correct |
4 ms |
10332 KB |
Output is correct |
9 |
Correct |
4 ms |
10332 KB |
Output is correct |
10 |
Correct |
4 ms |
10332 KB |
Output is correct |
11 |
Correct |
43 ms |
12624 KB |
Output is correct |
12 |
Correct |
4 ms |
10332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
10588 KB |
Output is correct |
2 |
Correct |
10 ms |
10588 KB |
Output is correct |
3 |
Correct |
10 ms |
10588 KB |
Output is correct |
4 |
Correct |
9 ms |
10588 KB |
Output is correct |
5 |
Correct |
9 ms |
8540 KB |
Output is correct |
6 |
Correct |
4 ms |
8272 KB |
Output is correct |
7 |
Correct |
4 ms |
8312 KB |
Output is correct |
8 |
Correct |
4 ms |
8284 KB |
Output is correct |
9 |
Correct |
9 ms |
8652 KB |
Output is correct |
10 |
Correct |
4 ms |
8380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
16304 KB |
Output is correct |
2 |
Correct |
46 ms |
16216 KB |
Output is correct |
3 |
Correct |
46 ms |
16220 KB |
Output is correct |
4 |
Correct |
71 ms |
17588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
10584 KB |
Output is correct |
2 |
Correct |
9 ms |
10588 KB |
Output is correct |
3 |
Correct |
10 ms |
10588 KB |
Output is correct |
4 |
Correct |
9 ms |
10552 KB |
Output is correct |
5 |
Correct |
10 ms |
10588 KB |
Output is correct |
6 |
Correct |
47 ms |
16304 KB |
Output is correct |
7 |
Correct |
47 ms |
16216 KB |
Output is correct |
8 |
Correct |
45 ms |
16216 KB |
Output is correct |
9 |
Correct |
65 ms |
17492 KB |
Output is correct |
10 |
Correct |
10 ms |
12124 KB |
Output is correct |
11 |
Correct |
12 ms |
12380 KB |
Output is correct |
12 |
Correct |
47 ms |
14968 KB |
Output is correct |
13 |
Correct |
10 ms |
12120 KB |
Output is correct |
14 |
Correct |
10 ms |
12120 KB |
Output is correct |
15 |
Correct |
3 ms |
8284 KB |
Output is correct |
16 |
Correct |
4 ms |
8640 KB |
Output is correct |
17 |
Correct |
4 ms |
8280 KB |
Output is correct |
18 |
Correct |
4 ms |
10332 KB |
Output is correct |
19 |
Correct |
4 ms |
10332 KB |
Output is correct |
20 |
Correct |
4 ms |
10332 KB |
Output is correct |
21 |
Correct |
4 ms |
10348 KB |
Output is correct |
22 |
Correct |
4 ms |
10332 KB |
Output is correct |
23 |
Correct |
4 ms |
10332 KB |
Output is correct |
24 |
Correct |
4 ms |
10332 KB |
Output is correct |
25 |
Correct |
44 ms |
12764 KB |
Output is correct |
26 |
Correct |
4 ms |
10336 KB |
Output is correct |
27 |
Correct |
8 ms |
10588 KB |
Output is correct |
28 |
Execution timed out |
20102 ms |
19804 KB |
Time limit exceeded |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
10588 KB |
Output is correct |
2 |
Correct |
10 ms |
10588 KB |
Output is correct |
3 |
Correct |
11 ms |
10648 KB |
Output is correct |
4 |
Correct |
10 ms |
10588 KB |
Output is correct |
5 |
Correct |
10 ms |
10644 KB |
Output is correct |
6 |
Correct |
46 ms |
16220 KB |
Output is correct |
7 |
Correct |
48 ms |
16216 KB |
Output is correct |
8 |
Correct |
47 ms |
16216 KB |
Output is correct |
9 |
Correct |
79 ms |
17528 KB |
Output is correct |
10 |
Correct |
10 ms |
12124 KB |
Output is correct |
11 |
Correct |
11 ms |
12380 KB |
Output is correct |
12 |
Correct |
51 ms |
15008 KB |
Output is correct |
13 |
Correct |
11 ms |
12124 KB |
Output is correct |
14 |
Correct |
11 ms |
12120 KB |
Output is correct |
15 |
Correct |
145 ms |
25748 KB |
Output is correct |
16 |
Execution timed out |
20070 ms |
24084 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |