#include <bits/stdc++.h>
#include "wombats.h"
using namespace std;
const int N=5e3+55;
int sum[N][2][2];
int v[N][2];
int h[N][2];
int n,m;
void build()
{
sum[0][0][1]=h[0][0];
sum[0][1][1]=h[0][0];
for(int i=1;i<n;i++)
{
for(int j=0;j<m;j++)
{
sum[i][j][0]=min(sum[i-1][j][0]+v[i-1][j],sum[i-1][j==0?1:0][0]+h[i][0]);
sum[i][j][1]=min(sum[i-1][j][1]+v[i-1][j],sum[i-1][j==0?1:0][1]+h[i][0]);
}
}
}
void init(int R, int C, int H[5000][200], int V[5000][200])
{
n=R;
m=C;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
v[i][j]=V[i][j];
h[i][j]=H[i][j];
}
}
build();
}
void changeH(int P, int Q, int W)
{
h[P][Q]=W;
build();
}
void changeV(int P, int Q, int W)
{
v[P][Q]=W;
build();
}
int escape(int V1, int V2)
{
return sum[n-1][V2][V1];
}
Compilation message
grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
int res;
^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
4344 KB |
Output is correct |
2 |
Incorrect |
21 ms |
4456 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4456 KB |
Output is correct |
2 |
Incorrect |
2 ms |
4456 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
4456 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
29 ms |
8612 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
8612 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
8612 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |