#include "wombats.h"
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,m,i,j,x[5050][220],y[5050][220],jum,d[2][5050][2];
void upd()
{
ll ii;
d[0][n-1][0]=0;
d[0][n-1][1]=x[n-1][0];
d[1][n-1][1]=0;
d[1][n-1][0]=x[n-1][0];
for(ii=n-2;ii>=0;ii--)
{
d[0][ii][0]=min(d[0][ii+1][0]+y[ii][0],d[0][ii+1][1]+y[ii][1]+x[ii][0]);
d[0][ii][1]=min(d[0][ii+1][1]+y[ii][1],d[0][ii+1][0]+y[ii][0]+x[ii][0]);
d[1][ii][0]=min(d[1][ii+1][0]+y[ii][0],d[1][ii+1][1]+y[ii][1]+x[ii][0]);
d[1][ii][1]=min(d[1][ii+1][1]+y[ii][1],d[1][ii+1][0]+y[ii][0]+x[ii][0]);
}
}
void init(int R, int C, int H[5000][200], int V[5000][200])
{
n=R;
m=C;
for(i=0;i<n;i++)
for(j=1;j<(m-1);j++)
x[i][j]=H[i][j];
for(i=0;i<(n-1);i++)
for(j=0;j<m;j++)
y[i][j]=V[i][j];
if(m==2)
{
upd();
}
else
{
while(1);
for(i=0;i<(n-1);i++)
jum+=y[i][0];
}
/* ... */
}
void changeH(int P, int Q, int W)
{
if(m==2)
{
x[P][Q]=W;
upd();
}
/* ... */
}
void changeV(int P, int Q, int W) {
if(m==2)
{
y[P][Q]=W;
upd();
}
else
{
jum-=y[P][Q];
y[P][Q]=W;
jum+=y[P][Q];
}
/* ... */
}
int escape(int V1, int V2)
{
if(m==2)
{
return d[V2][0][V1];
}
else
{
return jum;
}
}
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 |
Execution timed out |
20049 ms |
12928 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
20100 ms |
256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
20053 ms |
768 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
52 ms |
17812 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
20097 ms |
896 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
20019 ms |
768 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |