#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
int (*h)[200];
int (*v)[200];
int r,c; //r: height c: width
int INF = 1e9;
int cache[5000][5000];
void init(int R, int C, int H[5000][200], int V[5000][200]) {
/* ... */
h=H;v=V;
r=R;c=C;
for (int i = 0; i<c; i++){
cache[i][0]=-1;
}
}
void changeH(int P, int Q, int W) {
/* ... */
h[P][Q]=W;
for (int i = 0; i<c; i++){
cache[i][0]=-1;
}
}
void changeV(int P, int Q, int W) {
/* ... */
v[P][Q]=W;
for (int i = 0; i<c; i++){
cache[i][0]=-1;
}
}
int harr[2][5000];
int prefsum[5000];
int escape(int vtop, int vbot) {
if (cache[vtop][0]!=-1){
return cache[vtop][vbot];
}
for (int i = 0; i<c; i++){
harr[0][i]=INF;
}
harr[0][vtop]=0;
bool cur = 1;
for (int y = 1; y<=r; y++){
//process row h[y-1][x] and v[y-1][x]
prefsum[0]=0;
for (int x = 0; x<c-1; x++){
prefsum[x+1]=prefsum[x]+h[y-1][x];
}
int minval = INF;
for (int x = c-1; x>=0; x--){
int vert = (y==r)?0:v[y-1][x];
//cout<<prefsum[x]<<' ';
minval=min(minval,prefsum[x]+harr[!cur][x]);
harr[cur][x]=minval-prefsum[x]+vert;
}//cout<<'\n';
prefsum[c-1]=0;
for (int x = c-2; x>=0; x--){
prefsum[x]=prefsum[x+1]+h[y-1][x];
}
minval = INF;
for (int x = 0; x<c; x++){
int vert = (y==r)?0:v[y-1][x];
minval=min(minval,prefsum[x]+harr[!cur][x]);
harr[cur][x]=min(harr[cur][x],minval-prefsum[x]+vert);
}
/*for (int i = 0; i<c; i++){
cout<<harr[cur][i]<<' ';
}cout<<'\n';*/
cur=!cur;
}
for (int x = 0; x<c; x++){
cache[vtop][vbot]=harr[!cur][vbot];
}
return harr[!cur][vbot];
}
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;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
4224 KB |
Output is correct |
2 |
Correct |
28 ms |
4224 KB |
Output is correct |
3 |
Correct |
113 ms |
5880 KB |
Output is correct |
4 |
Correct |
31 ms |
4224 KB |
Output is correct |
5 |
Correct |
40 ms |
4224 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Incorrect |
2 ms |
512 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
896 KB |
Output is correct |
2 |
Correct |
14 ms |
896 KB |
Output is correct |
3 |
Correct |
11 ms |
896 KB |
Output is correct |
4 |
Correct |
11 ms |
896 KB |
Output is correct |
5 |
Correct |
13 ms |
896 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
512 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Incorrect |
7 ms |
896 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
86 ms |
8192 KB |
Output is correct |
2 |
Correct |
88 ms |
8192 KB |
Output is correct |
3 |
Correct |
88 ms |
8192 KB |
Output is correct |
4 |
Incorrect |
218 ms |
9080 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
896 KB |
Output is correct |
2 |
Correct |
11 ms |
896 KB |
Output is correct |
3 |
Correct |
11 ms |
896 KB |
Output is correct |
4 |
Correct |
13 ms |
896 KB |
Output is correct |
5 |
Correct |
11 ms |
916 KB |
Output is correct |
6 |
Correct |
87 ms |
8192 KB |
Output is correct |
7 |
Correct |
92 ms |
8192 KB |
Output is correct |
8 |
Correct |
106 ms |
8192 KB |
Output is correct |
9 |
Incorrect |
208 ms |
8952 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
896 KB |
Output is correct |
2 |
Correct |
10 ms |
896 KB |
Output is correct |
3 |
Correct |
14 ms |
896 KB |
Output is correct |
4 |
Correct |
12 ms |
896 KB |
Output is correct |
5 |
Correct |
12 ms |
896 KB |
Output is correct |
6 |
Correct |
87 ms |
8212 KB |
Output is correct |
7 |
Correct |
95 ms |
8192 KB |
Output is correct |
8 |
Correct |
89 ms |
8312 KB |
Output is correct |
9 |
Incorrect |
213 ms |
8952 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |