#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
#include "wombats.h"
int R,C;
int H[5000][200];
int V[5000][200];
int dp[5000][200];
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-1;j++){
H[i][j]=_H[i][j];
}
}
for(int i=0;i<R-1;i++){
for(int j=0;j<C;j++){
V[i][j]=_V[i][j];
}
}
}
void changeH(int P, int Q, int W) {
H[P][Q]=W;
}
void changeV(int P, int Q, int W) {
V[P][Q]=W;
}
int escape(int v1, int v2) {
dp[0][v1]=0;
int sum=0;
for(int i=v1-1;i>=0;i--){
sum+=H[0][i];
dp[0][i]=sum;
}
sum=0;
for(int i=v1;i<C-1;i++){
sum+=H[0][i];
dp[0][i+1]=sum;
}
int l[5000],r[5000];
for(int i=1;i<R;i++){
for(int j=0;j<C;j++){
l[j]=dp[i-1][j]+V[i-1][j];
if(j)l[j]=min(l[j],l[j-1]+H[i][j-1]);
}
for(int j=C-1;j>=0;j--){
r[j]=dp[i-1][j]+V[i-1][j];
if(j<C-1)r[j]=min(r[j],r[j+1]+H[i][j]);
}
for(int j=0;j<C;j++){
dp[i][j]=min(l[j],r[j]);
}
}
return dp[R-1][v2];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
20612 KB |
Output is correct - 505 tokens |
2 |
Correct |
26 ms |
20612 KB |
Output is correct - 505 tokens |
3 |
Correct |
8815 ms |
20612 KB |
Output is correct - 200005 tokens |
4 |
Correct |
26 ms |
20612 KB |
Output is correct - 505 tokens |
5 |
Correct |
26 ms |
20612 KB |
Output is correct - 505 tokens |
6 |
Correct |
0 ms |
20612 KB |
Output is correct - 6 tokens |
7 |
Correct |
0 ms |
20612 KB |
Output is correct - 6 tokens |
8 |
Correct |
0 ms |
20612 KB |
Output is correct - 6 tokens |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
20612 KB |
Output is correct - 6 tokens |
2 |
Correct |
0 ms |
20612 KB |
Output is correct - 6 tokens |
3 |
Correct |
0 ms |
20612 KB |
Output is correct - 6 tokens |
4 |
Correct |
3 ms |
20612 KB |
Output is correct - 405 tokens |
5 |
Correct |
0 ms |
20612 KB |
Output is correct - 405 tokens |
6 |
Correct |
0 ms |
20612 KB |
Output is correct - 405 tokens |
7 |
Correct |
0 ms |
20612 KB |
Output is correct - 405 tokens |
8 |
Correct |
2 ms |
20612 KB |
Output is correct - 366 tokens |
9 |
Correct |
0 ms |
20612 KB |
Output is correct - 405 tokens |
10 |
Correct |
2 ms |
20612 KB |
Output is correct - 366 tokens |
11 |
Correct |
817 ms |
20612 KB |
Output is correct - 200005 tokens |
12 |
Correct |
0 ms |
20612 KB |
Output is correct - 405 tokens |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
20612 KB |
Output is correct - 105 tokens |
2 |
Correct |
15 ms |
20612 KB |
Output is correct - 105 tokens |
3 |
Correct |
11 ms |
20612 KB |
Output is correct - 105 tokens |
4 |
Correct |
14 ms |
20612 KB |
Output is correct - 105 tokens |
5 |
Correct |
12 ms |
20612 KB |
Output is correct - 105 tokens |
6 |
Correct |
0 ms |
20612 KB |
Output is correct - 6 tokens |
7 |
Correct |
0 ms |
20612 KB |
Output is correct - 6 tokens |
8 |
Correct |
0 ms |
20612 KB |
Output is correct - 6 tokens |
9 |
Correct |
10 ms |
20612 KB |
Output is correct - 105 tokens |
10 |
Correct |
0 ms |
20612 KB |
Output is correct - 8 tokens |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
86 ms |
20612 KB |
Output is correct - 1005 tokens |
2 |
Correct |
83 ms |
20612 KB |
Output is correct - 1005 tokens |
3 |
Correct |
90 ms |
20612 KB |
Output is correct - 1005 tokens |
4 |
Correct |
8528 ms |
20612 KB |
Output is correct - 100005 tokens |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
20612 KB |
Output is correct - 105 tokens |
2 |
Correct |
7 ms |
20612 KB |
Output is correct - 105 tokens |
3 |
Correct |
10 ms |
20612 KB |
Output is correct - 105 tokens |
4 |
Correct |
11 ms |
20612 KB |
Output is correct - 105 tokens |
5 |
Correct |
14 ms |
20612 KB |
Output is correct - 105 tokens |
6 |
Correct |
87 ms |
20612 KB |
Output is correct - 1005 tokens |
7 |
Correct |
87 ms |
20612 KB |
Output is correct - 1005 tokens |
8 |
Correct |
89 ms |
20612 KB |
Output is correct - 1005 tokens |
9 |
Correct |
8655 ms |
20612 KB |
Output is correct - 100005 tokens |
10 |
Correct |
26 ms |
20612 KB |
Output is correct - 505 tokens |
11 |
Correct |
22 ms |
20612 KB |
Output is correct - 505 tokens |
12 |
Correct |
8788 ms |
20612 KB |
Output is correct - 200005 tokens |
13 |
Correct |
21 ms |
20612 KB |
Output is correct - 505 tokens |
14 |
Correct |
25 ms |
20612 KB |
Output is correct - 505 tokens |
15 |
Correct |
0 ms |
20612 KB |
Output is correct - 6 tokens |
16 |
Correct |
0 ms |
20612 KB |
Output is correct - 6 tokens |
17 |
Correct |
0 ms |
20612 KB |
Output is correct - 6 tokens |
18 |
Correct |
0 ms |
20612 KB |
Output is correct - 405 tokens |
19 |
Correct |
0 ms |
20612 KB |
Output is correct - 405 tokens |
20 |
Correct |
0 ms |
20612 KB |
Output is correct - 405 tokens |
21 |
Correct |
2 ms |
20612 KB |
Output is correct - 405 tokens |
22 |
Correct |
3 ms |
20612 KB |
Output is correct - 366 tokens |
23 |
Correct |
0 ms |
20612 KB |
Output is correct - 405 tokens |
24 |
Correct |
3 ms |
20612 KB |
Output is correct - 366 tokens |
25 |
Correct |
808 ms |
20612 KB |
Output is correct - 200005 tokens |
26 |
Correct |
2 ms |
20612 KB |
Output is correct - 405 tokens |
27 |
Correct |
9 ms |
20612 KB |
Output is correct - 105 tokens |
28 |
Execution timed out |
20000 ms |
20612 KB |
Program timed out |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
20612 KB |
Output is correct - 105 tokens |
2 |
Correct |
10 ms |
20612 KB |
Output is correct - 105 tokens |
3 |
Correct |
11 ms |
20612 KB |
Output is correct - 105 tokens |
4 |
Correct |
11 ms |
20612 KB |
Output is correct - 105 tokens |
5 |
Correct |
7 ms |
20612 KB |
Output is correct - 105 tokens |
6 |
Correct |
89 ms |
20612 KB |
Output is correct - 1005 tokens |
7 |
Correct |
86 ms |
20612 KB |
Output is correct - 1005 tokens |
8 |
Correct |
83 ms |
20612 KB |
Output is correct - 1005 tokens |
9 |
Correct |
8543 ms |
20612 KB |
Output is correct - 100005 tokens |
10 |
Correct |
22 ms |
20612 KB |
Output is correct - 505 tokens |
11 |
Correct |
25 ms |
20612 KB |
Output is correct - 505 tokens |
12 |
Correct |
8815 ms |
20612 KB |
Output is correct - 200005 tokens |
13 |
Correct |
22 ms |
20612 KB |
Output is correct - 505 tokens |
14 |
Correct |
22 ms |
20612 KB |
Output is correct - 505 tokens |
15 |
Correct |
317 ms |
20612 KB |
Output is correct - 11 tokens |
16 |
Execution timed out |
20000 ms |
20612 KB |
Program timed out |
17 |
Halted |
0 ms |
0 KB |
- |