#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
int n,m,r[5000][200],d[5000][200];
void cmin(int&a,int b) {if(a>b)a=b;}
struct ini
{
int s[200][200];
bool go;
};
ini gen(int t)
{
//r[t],r[t+1],d[t]
ini u; u.go=1;
for(int i=0;i<m;++i)
{
u.s[i][i]=d[t][i];
for(int j=i;j+1<m;++j)
u.s[i][j+1]=u.s[i][j]+r[t+1][j];
for(int j=i-1;j>=0;--j)
u.s[i][j]=u.s[i][j+1]+r[t+1][j];
}
for(int i=0;i<m;++i)
{
for(int j=0;j+1<m;++j)
cmin(u.s[j+1][i],u.s[j][i]+r[t][j]);
for(int j=m-2;j>=0;--j)
cmin(u.s[j][i],u.s[j+1][i]+r[t][j]);
}
return u;
}
ini operator * (const ini&a,const ini&b)
{
if(!a.go) return b;
if(!b.go) return a;
ini u;
for(int i=0;i<m;++i)
for(int j=0;j<m;++j)
{
int x=2.01e9;
for(int k=0;k<m;++k)
cmin(x,a.s[i][k]+b.s[k][j]);
u.s[i][j]=x;
}
return u;
}
void init(int R, int C, int H[5000][200], int V[5000][200]) {
n=R; m=C;
memcpy(r,H,sizeof r);
memcpy(d,V,sizeof d);
}
void changeH(int P, int Q, int W) {
r[P][Q]=W;
}
void changeV(int P, int Q, int W) {
d[P][Q]=W;
}
int escape(int V1, int V2) {
ini x; x.go=0;
for(int t=0;t<n-1;++t)
x=x*gen(t);
return x.s[V1][V2];
}
//prototype.
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 |
20045 ms |
12536 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
8568 KB |
Output is correct |
2 |
Correct |
10 ms |
8440 KB |
Output is correct |
3 |
Correct |
10 ms |
8440 KB |
Output is correct |
4 |
Incorrect |
215 ms |
8668 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4767 ms |
9040 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
20025 ms |
16504 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4782 ms |
8952 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4896 ms |
8912 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |