# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
578220 |
2022-06-16T08:37:06 Z |
handlename |
Game (APIO22_game) |
C++17 |
|
1390 ms |
262144 KB |
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
const int MOD=1e9+7;
int n,k;
vector<int> adj[300001],rev[300001];
struct node{
node *l,*r;
//left node stores stuff which can reach m
//right node stores stuff which m can reach
int s,m,e;
unordered_set<int> stuff;
node(int ss,int ee){
s=ss;
e=ee;
m=(s+e)/2;
if (s<e){
l=new node(s,m);
r=new node(m+1,e);
for (int i=s;i<=m;i++) l->stuff.insert(i);
for (int i=m;i<=e;i++) r->stuff.insert(i);
}
if (s==e){
l=new node(s,-1);
r=new node(s,-1);
l->stuff.insert(s);
r->stuff.insert(s);
}
}
bool upd(int u,int v){
if (e==-1) return false;
/*
cout<<"update "<<s<<' '<<m<<' '<<e<<' '<<u<<' '<<v<<'\n';
cout<<"left: ";
for (auto i:l->stuff) cout<<i<<' ';
cout<<'\n';
cout<<"right: ";
for (auto i:r->stuff) cout<<i<<' ';
cout<<'\n';
*/
bool uleft=(l->stuff.find(u)!=l->stuff.end());
bool uright=(r->stuff.find(u)!=r->stuff.end());
bool vleft=(l->stuff.find(v)!=l->stuff.end());
bool vright=(r->stuff.find(v)!=r->stuff.end());
if (uright){
if (vleft) return true;
if (vright) return r->upd(u,v);
r->stuff.insert(v);
if (r->upd(u,v)) return true;
for (auto i:adj[v]){
if (l->stuff.find(i)!=l->stuff.end()){
return true;
}
if (n<=40000 || r->stuff.find(i)==r->stuff.end()){
if (upd(v,i)) return true;
}
}
}
if (vleft){
if (uleft) return l->upd(u,v);
l->stuff.insert(u);
if (l->upd(u,v)) return true;
for (auto i:rev[u]){
if (r->stuff.find(i)!=r->stuff.end()){
return true;
}
if (n<=40000 || l->stuff.find(i)==l->stuff.end()){
if (upd(i,u)) return true;
}
}
}
return false;
}
}*root;
void init(int N,int K){
n=N;
k=K;
for (int i=1;i<k;i++){
//adj[i].pb(i+1);
//rev[i+1].pb(i);
}
root=new node(1,k);
}
int add_teleporter(int u,int v){
u++;
v++;
adj[u].pb(v);
rev[v].pb(u);
if (u>=v && u<=k) return 1;
if (u==v) return 0;
return root->upd(u,v);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
8 ms |
14416 KB |
Output is correct |
4 |
Correct |
8 ms |
14416 KB |
Output is correct |
5 |
Correct |
8 ms |
14416 KB |
Output is correct |
6 |
Correct |
8 ms |
14416 KB |
Output is correct |
7 |
Correct |
8 ms |
14416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
8 ms |
14416 KB |
Output is correct |
4 |
Correct |
8 ms |
14416 KB |
Output is correct |
5 |
Correct |
8 ms |
14416 KB |
Output is correct |
6 |
Correct |
8 ms |
14416 KB |
Output is correct |
7 |
Correct |
8 ms |
14416 KB |
Output is correct |
8 |
Correct |
7 ms |
14268 KB |
Output is correct |
9 |
Correct |
7 ms |
14288 KB |
Output is correct |
10 |
Correct |
8 ms |
14288 KB |
Output is correct |
11 |
Correct |
8 ms |
14288 KB |
Output is correct |
12 |
Correct |
8 ms |
14396 KB |
Output is correct |
13 |
Correct |
8 ms |
14288 KB |
Output is correct |
14 |
Correct |
10 ms |
14416 KB |
Output is correct |
15 |
Correct |
9 ms |
14440 KB |
Output is correct |
16 |
Correct |
9 ms |
14404 KB |
Output is correct |
17 |
Correct |
9 ms |
14416 KB |
Output is correct |
18 |
Correct |
8 ms |
14416 KB |
Output is correct |
19 |
Correct |
9 ms |
14416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
8 ms |
14416 KB |
Output is correct |
4 |
Correct |
8 ms |
14416 KB |
Output is correct |
5 |
Correct |
8 ms |
14416 KB |
Output is correct |
6 |
Correct |
8 ms |
14416 KB |
Output is correct |
7 |
Correct |
8 ms |
14416 KB |
Output is correct |
8 |
Correct |
7 ms |
14268 KB |
Output is correct |
9 |
Correct |
7 ms |
14288 KB |
Output is correct |
10 |
Correct |
8 ms |
14288 KB |
Output is correct |
11 |
Correct |
8 ms |
14288 KB |
Output is correct |
12 |
Correct |
8 ms |
14396 KB |
Output is correct |
13 |
Correct |
8 ms |
14288 KB |
Output is correct |
14 |
Correct |
10 ms |
14416 KB |
Output is correct |
15 |
Correct |
9 ms |
14440 KB |
Output is correct |
16 |
Correct |
9 ms |
14404 KB |
Output is correct |
17 |
Correct |
9 ms |
14416 KB |
Output is correct |
18 |
Correct |
8 ms |
14416 KB |
Output is correct |
19 |
Correct |
9 ms |
14416 KB |
Output is correct |
20 |
Correct |
9 ms |
14416 KB |
Output is correct |
21 |
Correct |
8 ms |
14416 KB |
Output is correct |
22 |
Correct |
10 ms |
14672 KB |
Output is correct |
23 |
Correct |
9 ms |
14408 KB |
Output is correct |
24 |
Correct |
11 ms |
15440 KB |
Output is correct |
25 |
Correct |
13 ms |
15236 KB |
Output is correct |
26 |
Correct |
15 ms |
14800 KB |
Output is correct |
27 |
Correct |
18 ms |
15372 KB |
Output is correct |
28 |
Correct |
11 ms |
15312 KB |
Output is correct |
29 |
Correct |
14 ms |
15376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
8 ms |
14416 KB |
Output is correct |
4 |
Correct |
8 ms |
14416 KB |
Output is correct |
5 |
Correct |
8 ms |
14416 KB |
Output is correct |
6 |
Correct |
8 ms |
14416 KB |
Output is correct |
7 |
Correct |
8 ms |
14416 KB |
Output is correct |
8 |
Correct |
7 ms |
14268 KB |
Output is correct |
9 |
Correct |
7 ms |
14288 KB |
Output is correct |
10 |
Correct |
8 ms |
14288 KB |
Output is correct |
11 |
Correct |
8 ms |
14288 KB |
Output is correct |
12 |
Correct |
8 ms |
14396 KB |
Output is correct |
13 |
Correct |
8 ms |
14288 KB |
Output is correct |
14 |
Correct |
10 ms |
14416 KB |
Output is correct |
15 |
Correct |
9 ms |
14440 KB |
Output is correct |
16 |
Correct |
9 ms |
14404 KB |
Output is correct |
17 |
Correct |
9 ms |
14416 KB |
Output is correct |
18 |
Correct |
8 ms |
14416 KB |
Output is correct |
19 |
Correct |
9 ms |
14416 KB |
Output is correct |
20 |
Correct |
9 ms |
14416 KB |
Output is correct |
21 |
Correct |
8 ms |
14416 KB |
Output is correct |
22 |
Correct |
10 ms |
14672 KB |
Output is correct |
23 |
Correct |
9 ms |
14408 KB |
Output is correct |
24 |
Correct |
11 ms |
15440 KB |
Output is correct |
25 |
Correct |
13 ms |
15236 KB |
Output is correct |
26 |
Correct |
15 ms |
14800 KB |
Output is correct |
27 |
Correct |
18 ms |
15372 KB |
Output is correct |
28 |
Correct |
11 ms |
15312 KB |
Output is correct |
29 |
Correct |
14 ms |
15376 KB |
Output is correct |
30 |
Correct |
31 ms |
15708 KB |
Output is correct |
31 |
Correct |
15 ms |
16080 KB |
Output is correct |
32 |
Correct |
70 ms |
21428 KB |
Output is correct |
33 |
Correct |
30 ms |
16872 KB |
Output is correct |
34 |
Correct |
95 ms |
35788 KB |
Output is correct |
35 |
Correct |
146 ms |
35712 KB |
Output is correct |
36 |
Correct |
150 ms |
26788 KB |
Output is correct |
37 |
Correct |
226 ms |
33260 KB |
Output is correct |
38 |
Correct |
387 ms |
61344 KB |
Output is correct |
39 |
Correct |
348 ms |
53992 KB |
Output is correct |
40 |
Correct |
115 ms |
35224 KB |
Output is correct |
41 |
Correct |
142 ms |
34216 KB |
Output is correct |
42 |
Correct |
95 ms |
26280 KB |
Output is correct |
43 |
Runtime error |
1390 ms |
262144 KB |
Execution killed with signal 9 |
44 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
8 ms |
14416 KB |
Output is correct |
4 |
Correct |
8 ms |
14416 KB |
Output is correct |
5 |
Correct |
8 ms |
14416 KB |
Output is correct |
6 |
Correct |
8 ms |
14416 KB |
Output is correct |
7 |
Correct |
8 ms |
14416 KB |
Output is correct |
8 |
Correct |
7 ms |
14268 KB |
Output is correct |
9 |
Correct |
7 ms |
14288 KB |
Output is correct |
10 |
Correct |
8 ms |
14288 KB |
Output is correct |
11 |
Correct |
8 ms |
14288 KB |
Output is correct |
12 |
Correct |
8 ms |
14396 KB |
Output is correct |
13 |
Correct |
8 ms |
14288 KB |
Output is correct |
14 |
Correct |
10 ms |
14416 KB |
Output is correct |
15 |
Correct |
9 ms |
14440 KB |
Output is correct |
16 |
Correct |
9 ms |
14404 KB |
Output is correct |
17 |
Correct |
9 ms |
14416 KB |
Output is correct |
18 |
Correct |
8 ms |
14416 KB |
Output is correct |
19 |
Correct |
9 ms |
14416 KB |
Output is correct |
20 |
Correct |
9 ms |
14416 KB |
Output is correct |
21 |
Correct |
8 ms |
14416 KB |
Output is correct |
22 |
Correct |
10 ms |
14672 KB |
Output is correct |
23 |
Correct |
9 ms |
14408 KB |
Output is correct |
24 |
Correct |
11 ms |
15440 KB |
Output is correct |
25 |
Correct |
13 ms |
15236 KB |
Output is correct |
26 |
Correct |
15 ms |
14800 KB |
Output is correct |
27 |
Correct |
18 ms |
15372 KB |
Output is correct |
28 |
Correct |
11 ms |
15312 KB |
Output is correct |
29 |
Correct |
14 ms |
15376 KB |
Output is correct |
30 |
Correct |
31 ms |
15708 KB |
Output is correct |
31 |
Correct |
15 ms |
16080 KB |
Output is correct |
32 |
Correct |
70 ms |
21428 KB |
Output is correct |
33 |
Correct |
30 ms |
16872 KB |
Output is correct |
34 |
Correct |
95 ms |
35788 KB |
Output is correct |
35 |
Correct |
146 ms |
35712 KB |
Output is correct |
36 |
Correct |
150 ms |
26788 KB |
Output is correct |
37 |
Correct |
226 ms |
33260 KB |
Output is correct |
38 |
Correct |
387 ms |
61344 KB |
Output is correct |
39 |
Correct |
348 ms |
53992 KB |
Output is correct |
40 |
Correct |
115 ms |
35224 KB |
Output is correct |
41 |
Correct |
142 ms |
34216 KB |
Output is correct |
42 |
Correct |
95 ms |
26280 KB |
Output is correct |
43 |
Runtime error |
1390 ms |
262144 KB |
Execution killed with signal 9 |
44 |
Halted |
0 ms |
0 KB |
- |