# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
202408 |
2020-02-16T03:55:58 Z |
gs18115 |
Wombats (IOI13_wombats) |
C++14 |
|
20000 ms |
132472 KB |
#include"wombats.h"
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define semicolon ;
#define ryan bear
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18+7;
struct node
{
int l,r;
int d[200][200];
}tr[1500];
int r,c;
int opt[200][200];
inline void merge(int n,int l,int r)
{
node&m=tr[n];
node&x=tr[l];
node&y=tr[r];
for(int i=0;i<c;i++)
for(int j=0;j<c;j++)
opt[i][j]=-1;
for(int i=0;i<c;i++)
{
int j=0;
for(int k=0;k<c;k++)
{
int&o=opt[i][j]=0;
for(int k=0;++k<c;)
if(x.d[i][k]+y.d[k][j]<x.d[i][o]+y.d[o][j])
o=k;
}
}
for(int j=0;j<c;j++)
{
int i=c-1;
for(int k=0;k<c;k++)
{
int&o=opt[i][j]=0;
for(int k=0;++k<c;)
if(x.d[i][k]+y.d[k][j]<x.d[i][o]+y.d[o][j])
o=k;
}
}
for(int l=-c;++l<c;)
{
for(int i=0;i<c;i++)
{
int j=i+l;
if(j<0||j>=c||opt[i][j]!=-1)
continue;
int&o=opt[i][j]=opt[i][j-1];
for(int k=o;++k<=opt[i+1][j];)
if(x.d[i][k]+y.d[k][j]<x.d[i][o]+y.d[o][j])
o=k;
}
}
for(int i=0;i<c;i++)
for(int j=0;j<c;j++)
m.d[i][j]=x.d[i][opt[i][j]]+y.d[opt[i][j]][j];
return;
}
int dn;
vector<pi>adj[100010];
int d[100010];
inline void dijk(int s)
{
fill(d,d+dn,inf);
priority_queue<pi,vector<pi>,greater<pi> >pq;
pq.ep(d[s]=0,s);
while(!pq.empty())
{
int x=pq.top().se;
int cd=pq.top().fi;
pq.pop();
if(d[x]!=cd)
continue;
for(pi&t:adj[x])
if(d[t.fi]>cd+t.se)
pq.ep(d[t.fi]=cd+t.se,t.fi);
}
return;
}
vector<vector<int> >h,v;
inline void init(int n,int s,int e)
{
node&x=tr[n];
dn=(e-s+1)*c;
for(int i=0;i<dn;i++)
adj[i].clear();
for(int i=s;i<=e;i++)
{
for(int j=0;j<c-1;j++)
{
int cn=i*c-s*c+j;
adj[cn].eb(cn+1,h[i][j]);
adj[cn+1].eb(cn,h[i][j]);
}
}
for(int i=s;i<e;i++)
{
for(int j=0;j<c;j++)
{
int cn=i*c-s*c+j;
adj[cn].eb(cn+c,v[i][j]);
}
}
for(int i=0;i<c;i++)
{
dijk(i);
for(int j=0;j<c;j++)
x.d[i][j]=d[j+(e-s)*c];
}
return;
}
int tct=0,rt;
int init(int s,int e)
{
int cur=tct++;
node&x=tr[cur];
if(e-s<20)
{
x.l=x.r=0;
init(cur,s,e);
return cur;
}
int m=(s+e)/2;
x.l=init(s,m);
x.r=init(m,e);
merge(cur,x.l,x.r);
return cur;
}
void ch(int n,int s,int e,int r)
{
if(s>r||e<r)
return;
node&x=tr[n];
if(e-s<20)
{
init(n,s,e);
return;
}
int m=(s+e)/2;
ch(x.l,s,m,r);
ch(x.r,m,e,r);
merge(n,x.l,x.r);
return;
}
void cv(int n,int s,int e,int r)
{
if(s>r||e<=r)
return;
node&x=tr[n];
if(e-s<20)
{
init(n,s,e);
return;
}
int m=(s+e)/2;
cv(x.l,s,m,r);
cv(x.r,m,e,r);
merge(n,x.l,x.r);
return;
}
void init(int R,int C,int H[5000][200],int V[5000][200])
{
r=R;
c=C;
h.resize(r);
for(int i=0;i<r;i++)
for(int j=0;j<c-1;j++)
h[i].eb(H[i][j]);
v.resize(r-1);
for(int i=0;i<r-1;i++)
for(int j=0;j<c;j++)
v[i].eb(V[i][j]);
rt=init(0,r-1);
return;
}
void changeH(int P,int Q,int W)
{
h[P][Q]=W;
ch(rt,0,r-1,P);
return;
}
void changeV(int P,int Q,int W)
{
v[P][Q]=W;
cv(rt,0,r-1,P);
return;
}
int escape(int V1,int V2)
{
return tr[rt].d[V1][V2];
}
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 |
12 ms |
10360 KB |
Output is correct |
2 |
Correct |
13 ms |
10364 KB |
Output is correct |
3 |
Correct |
102 ms |
12792 KB |
Output is correct |
4 |
Correct |
13 ms |
10360 KB |
Output is correct |
5 |
Correct |
12 ms |
10360 KB |
Output is correct |
6 |
Correct |
6 ms |
2680 KB |
Output is correct |
7 |
Correct |
7 ms |
2680 KB |
Output is correct |
8 |
Correct |
6 ms |
2680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2680 KB |
Output is correct |
2 |
Correct |
7 ms |
2680 KB |
Output is correct |
3 |
Correct |
6 ms |
2680 KB |
Output is correct |
4 |
Correct |
7 ms |
2812 KB |
Output is correct |
5 |
Correct |
7 ms |
2808 KB |
Output is correct |
6 |
Correct |
7 ms |
2808 KB |
Output is correct |
7 |
Correct |
8 ms |
2808 KB |
Output is correct |
8 |
Correct |
8 ms |
2808 KB |
Output is correct |
9 |
Correct |
8 ms |
2808 KB |
Output is correct |
10 |
Correct |
8 ms |
2808 KB |
Output is correct |
11 |
Correct |
98 ms |
5112 KB |
Output is correct |
12 |
Correct |
8 ms |
2808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2693 ms |
4600 KB |
Output is correct |
2 |
Correct |
3562 ms |
4472 KB |
Output is correct |
3 |
Correct |
2806 ms |
4600 KB |
Output is correct |
4 |
Correct |
2685 ms |
4588 KB |
Output is correct |
5 |
Correct |
2706 ms |
4628 KB |
Output is correct |
6 |
Correct |
6 ms |
2680 KB |
Output is correct |
7 |
Correct |
7 ms |
2680 KB |
Output is correct |
8 |
Correct |
6 ms |
2680 KB |
Output is correct |
9 |
Correct |
17730 ms |
4508 KB |
Output is correct |
10 |
Correct |
6 ms |
2680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
15096 KB |
Output is correct |
2 |
Correct |
21 ms |
15096 KB |
Output is correct |
3 |
Correct |
20 ms |
15096 KB |
Output is correct |
4 |
Correct |
66 ms |
16504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2687 ms |
4596 KB |
Output is correct |
2 |
Correct |
3562 ms |
4468 KB |
Output is correct |
3 |
Correct |
2787 ms |
4484 KB |
Output is correct |
4 |
Correct |
2696 ms |
4600 KB |
Output is correct |
5 |
Correct |
2727 ms |
4476 KB |
Output is correct |
6 |
Correct |
21 ms |
15096 KB |
Output is correct |
7 |
Correct |
21 ms |
15096 KB |
Output is correct |
8 |
Correct |
20 ms |
15096 KB |
Output is correct |
9 |
Correct |
64 ms |
16504 KB |
Output is correct |
10 |
Correct |
12 ms |
10360 KB |
Output is correct |
11 |
Correct |
12 ms |
10360 KB |
Output is correct |
12 |
Correct |
101 ms |
13176 KB |
Output is correct |
13 |
Correct |
12 ms |
10360 KB |
Output is correct |
14 |
Correct |
12 ms |
10360 KB |
Output is correct |
15 |
Correct |
6 ms |
2680 KB |
Output is correct |
16 |
Correct |
7 ms |
2680 KB |
Output is correct |
17 |
Correct |
6 ms |
2680 KB |
Output is correct |
18 |
Correct |
8 ms |
2808 KB |
Output is correct |
19 |
Correct |
7 ms |
2808 KB |
Output is correct |
20 |
Correct |
7 ms |
2808 KB |
Output is correct |
21 |
Correct |
8 ms |
2808 KB |
Output is correct |
22 |
Correct |
8 ms |
2812 KB |
Output is correct |
23 |
Correct |
8 ms |
2808 KB |
Output is correct |
24 |
Correct |
8 ms |
2808 KB |
Output is correct |
25 |
Correct |
101 ms |
5112 KB |
Output is correct |
26 |
Correct |
8 ms |
2808 KB |
Output is correct |
27 |
Correct |
17715 ms |
4600 KB |
Output is correct |
28 |
Execution timed out |
20015 ms |
84232 KB |
Time limit exceeded |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2805 ms |
4448 KB |
Output is correct |
2 |
Correct |
3659 ms |
4472 KB |
Output is correct |
3 |
Correct |
2806 ms |
4476 KB |
Output is correct |
4 |
Correct |
2681 ms |
4472 KB |
Output is correct |
5 |
Correct |
2718 ms |
4496 KB |
Output is correct |
6 |
Correct |
20 ms |
15096 KB |
Output is correct |
7 |
Correct |
21 ms |
15096 KB |
Output is correct |
8 |
Correct |
20 ms |
15096 KB |
Output is correct |
9 |
Correct |
63 ms |
16504 KB |
Output is correct |
10 |
Correct |
12 ms |
10364 KB |
Output is correct |
11 |
Correct |
12 ms |
10360 KB |
Output is correct |
12 |
Correct |
100 ms |
13304 KB |
Output is correct |
13 |
Correct |
13 ms |
10360 KB |
Output is correct |
14 |
Correct |
12 ms |
10360 KB |
Output is correct |
15 |
Execution timed out |
20083 ms |
132472 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |