#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; u.go=1;
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;
^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
20009 ms |
12536 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
Correct |
239 ms |
8568 KB |
Output is correct |
5 |
Correct |
224 ms |
8696 KB |
Output is correct |
6 |
Correct |
231 ms |
8568 KB |
Output is correct |
7 |
Correct |
226 ms |
8568 KB |
Output is correct |
8 |
Correct |
200 ms |
8568 KB |
Output is correct |
9 |
Correct |
226 ms |
8612 KB |
Output is correct |
10 |
Correct |
204 ms |
8668 KB |
Output is correct |
11 |
Execution timed out |
20058 ms |
9540 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8716 ms |
8844 KB |
Output is correct |
2 |
Correct |
8358 ms |
8904 KB |
Output is correct |
3 |
Correct |
8763 ms |
8952 KB |
Output is correct |
4 |
Correct |
8818 ms |
8956 KB |
Output is correct |
5 |
Correct |
8552 ms |
8952 KB |
Output is correct |
6 |
Correct |
11 ms |
8444 KB |
Output is correct |
7 |
Correct |
11 ms |
8568 KB |
Output is correct |
8 |
Correct |
10 ms |
8460 KB |
Output is correct |
9 |
Correct |
8705 ms |
8952 KB |
Output is correct |
10 |
Correct |
9 ms |
8568 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
20092 ms |
16248 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8689 ms |
8836 KB |
Output is correct |
2 |
Correct |
8362 ms |
8956 KB |
Output is correct |
3 |
Correct |
8815 ms |
9024 KB |
Output is correct |
4 |
Correct |
8771 ms |
8924 KB |
Output is correct |
5 |
Correct |
8614 ms |
8952 KB |
Output is correct |
6 |
Execution timed out |
20056 ms |
16412 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8668 ms |
8952 KB |
Output is correct |
2 |
Correct |
8344 ms |
8944 KB |
Output is correct |
3 |
Correct |
8802 ms |
8932 KB |
Output is correct |
4 |
Correct |
8768 ms |
9052 KB |
Output is correct |
5 |
Correct |
8568 ms |
8928 KB |
Output is correct |
6 |
Execution timed out |
20101 ms |
16380 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |