# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
588555 |
2022-07-03T13:54:11 Z |
jamezzz |
Game (APIO22_game) |
C++17 |
|
1591 ms |
87676 KB |
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define maxn 300005
//earliest node i can reach is in [m+1,r]
//latest that can reach node i is in [l,m]
int n,k,l[maxn],r[maxn],ans;
vector<int> in[maxn],out[maxn];
void init(int _n,int _k){
n=_n+1;k=_k+1;
for(int i=0;i<k;++i)l[i]=i,r[i]=i+1;
for(int i=k;i<n;++i)l[i]=0,r[i]=k;
}
void ppo(int u);
void fix(int u,int v){
if(r[u]<=l[v])return;//earliest v can reach after latest that can reach u, impossible
if(r[v]<=l[u]){//earliest that v can reach before latest that can reach u, possible
ans=1;
return;
}
if(l[u]==l[v]&&r[u]==r[v])return;
int um=(l[u]+r[u])>>1,vm=(l[v]+r[v])>>1;
if(r[v]<=um){//u can reach something earlier that is in bucket [l,m] so ppo down
r[u]=um;
ppo(u);
}
else if(vm<=l[u]){//something can reach v that is in bucket [m+1,r] so ppo down
l[v]=vm;
ppo(v);
}
}
void ppo(int u){
for(int v:out[u])fix(u,v);
for(int v:in[u])fix(v,u);
}
int add_teleporter(int u,int v){
++u,++v;
if(v<k)--v;
out[u].pb(v);
in[v].pb(u);
fix(u,v);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
14288 KB |
Output is correct |
2 |
Correct |
7 ms |
14288 KB |
Output is correct |
3 |
Correct |
8 ms |
14412 KB |
Output is correct |
4 |
Correct |
7 ms |
14288 KB |
Output is correct |
5 |
Correct |
7 ms |
14412 KB |
Output is correct |
6 |
Correct |
8 ms |
14384 KB |
Output is correct |
7 |
Correct |
8 ms |
14288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
14288 KB |
Output is correct |
2 |
Correct |
7 ms |
14288 KB |
Output is correct |
3 |
Correct |
8 ms |
14412 KB |
Output is correct |
4 |
Correct |
7 ms |
14288 KB |
Output is correct |
5 |
Correct |
7 ms |
14412 KB |
Output is correct |
6 |
Correct |
8 ms |
14384 KB |
Output is correct |
7 |
Correct |
8 ms |
14288 KB |
Output is correct |
8 |
Correct |
8 ms |
14288 KB |
Output is correct |
9 |
Correct |
8 ms |
14288 KB |
Output is correct |
10 |
Correct |
8 ms |
14288 KB |
Output is correct |
11 |
Correct |
9 ms |
14288 KB |
Output is correct |
12 |
Correct |
8 ms |
14288 KB |
Output is correct |
13 |
Correct |
9 ms |
14288 KB |
Output is correct |
14 |
Correct |
8 ms |
14288 KB |
Output is correct |
15 |
Correct |
8 ms |
14288 KB |
Output is correct |
16 |
Correct |
8 ms |
14288 KB |
Output is correct |
17 |
Correct |
10 ms |
14288 KB |
Output is correct |
18 |
Correct |
7 ms |
14288 KB |
Output is correct |
19 |
Correct |
8 ms |
14288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
14288 KB |
Output is correct |
2 |
Correct |
7 ms |
14288 KB |
Output is correct |
3 |
Correct |
8 ms |
14412 KB |
Output is correct |
4 |
Correct |
7 ms |
14288 KB |
Output is correct |
5 |
Correct |
7 ms |
14412 KB |
Output is correct |
6 |
Correct |
8 ms |
14384 KB |
Output is correct |
7 |
Correct |
8 ms |
14288 KB |
Output is correct |
8 |
Correct |
8 ms |
14288 KB |
Output is correct |
9 |
Correct |
8 ms |
14288 KB |
Output is correct |
10 |
Correct |
8 ms |
14288 KB |
Output is correct |
11 |
Correct |
9 ms |
14288 KB |
Output is correct |
12 |
Correct |
8 ms |
14288 KB |
Output is correct |
13 |
Correct |
9 ms |
14288 KB |
Output is correct |
14 |
Correct |
8 ms |
14288 KB |
Output is correct |
15 |
Correct |
8 ms |
14288 KB |
Output is correct |
16 |
Correct |
8 ms |
14288 KB |
Output is correct |
17 |
Correct |
10 ms |
14288 KB |
Output is correct |
18 |
Correct |
7 ms |
14288 KB |
Output is correct |
19 |
Correct |
8 ms |
14288 KB |
Output is correct |
20 |
Correct |
8 ms |
14416 KB |
Output is correct |
21 |
Correct |
8 ms |
14308 KB |
Output is correct |
22 |
Correct |
9 ms |
14544 KB |
Output is correct |
23 |
Correct |
8 ms |
14408 KB |
Output is correct |
24 |
Correct |
10 ms |
14416 KB |
Output is correct |
25 |
Correct |
11 ms |
14488 KB |
Output is correct |
26 |
Correct |
10 ms |
14416 KB |
Output is correct |
27 |
Correct |
11 ms |
14420 KB |
Output is correct |
28 |
Correct |
9 ms |
14420 KB |
Output is correct |
29 |
Correct |
9 ms |
14548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
14288 KB |
Output is correct |
2 |
Correct |
7 ms |
14288 KB |
Output is correct |
3 |
Correct |
8 ms |
14412 KB |
Output is correct |
4 |
Correct |
7 ms |
14288 KB |
Output is correct |
5 |
Correct |
7 ms |
14412 KB |
Output is correct |
6 |
Correct |
8 ms |
14384 KB |
Output is correct |
7 |
Correct |
8 ms |
14288 KB |
Output is correct |
8 |
Correct |
8 ms |
14288 KB |
Output is correct |
9 |
Correct |
8 ms |
14288 KB |
Output is correct |
10 |
Correct |
8 ms |
14288 KB |
Output is correct |
11 |
Correct |
9 ms |
14288 KB |
Output is correct |
12 |
Correct |
8 ms |
14288 KB |
Output is correct |
13 |
Correct |
9 ms |
14288 KB |
Output is correct |
14 |
Correct |
8 ms |
14288 KB |
Output is correct |
15 |
Correct |
8 ms |
14288 KB |
Output is correct |
16 |
Correct |
8 ms |
14288 KB |
Output is correct |
17 |
Correct |
10 ms |
14288 KB |
Output is correct |
18 |
Correct |
7 ms |
14288 KB |
Output is correct |
19 |
Correct |
8 ms |
14288 KB |
Output is correct |
20 |
Correct |
8 ms |
14416 KB |
Output is correct |
21 |
Correct |
8 ms |
14308 KB |
Output is correct |
22 |
Correct |
9 ms |
14544 KB |
Output is correct |
23 |
Correct |
8 ms |
14408 KB |
Output is correct |
24 |
Correct |
10 ms |
14416 KB |
Output is correct |
25 |
Correct |
11 ms |
14488 KB |
Output is correct |
26 |
Correct |
10 ms |
14416 KB |
Output is correct |
27 |
Correct |
11 ms |
14420 KB |
Output is correct |
28 |
Correct |
9 ms |
14420 KB |
Output is correct |
29 |
Correct |
9 ms |
14548 KB |
Output is correct |
30 |
Correct |
25 ms |
15744 KB |
Output is correct |
31 |
Correct |
12 ms |
14952 KB |
Output is correct |
32 |
Correct |
33 ms |
20604 KB |
Output is correct |
33 |
Correct |
26 ms |
16428 KB |
Output is correct |
34 |
Correct |
43 ms |
24532 KB |
Output is correct |
35 |
Correct |
51 ms |
17368 KB |
Output is correct |
36 |
Correct |
40 ms |
16484 KB |
Output is correct |
37 |
Correct |
44 ms |
16412 KB |
Output is correct |
38 |
Correct |
33 ms |
16184 KB |
Output is correct |
39 |
Correct |
37 ms |
16196 KB |
Output is correct |
40 |
Correct |
49 ms |
26424 KB |
Output is correct |
41 |
Correct |
48 ms |
17680 KB |
Output is correct |
42 |
Correct |
43 ms |
17840 KB |
Output is correct |
43 |
Correct |
41 ms |
17260 KB |
Output is correct |
44 |
Correct |
52 ms |
18656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
14288 KB |
Output is correct |
2 |
Correct |
7 ms |
14288 KB |
Output is correct |
3 |
Correct |
8 ms |
14412 KB |
Output is correct |
4 |
Correct |
7 ms |
14288 KB |
Output is correct |
5 |
Correct |
7 ms |
14412 KB |
Output is correct |
6 |
Correct |
8 ms |
14384 KB |
Output is correct |
7 |
Correct |
8 ms |
14288 KB |
Output is correct |
8 |
Correct |
8 ms |
14288 KB |
Output is correct |
9 |
Correct |
8 ms |
14288 KB |
Output is correct |
10 |
Correct |
8 ms |
14288 KB |
Output is correct |
11 |
Correct |
9 ms |
14288 KB |
Output is correct |
12 |
Correct |
8 ms |
14288 KB |
Output is correct |
13 |
Correct |
9 ms |
14288 KB |
Output is correct |
14 |
Correct |
8 ms |
14288 KB |
Output is correct |
15 |
Correct |
8 ms |
14288 KB |
Output is correct |
16 |
Correct |
8 ms |
14288 KB |
Output is correct |
17 |
Correct |
10 ms |
14288 KB |
Output is correct |
18 |
Correct |
7 ms |
14288 KB |
Output is correct |
19 |
Correct |
8 ms |
14288 KB |
Output is correct |
20 |
Correct |
8 ms |
14416 KB |
Output is correct |
21 |
Correct |
8 ms |
14308 KB |
Output is correct |
22 |
Correct |
9 ms |
14544 KB |
Output is correct |
23 |
Correct |
8 ms |
14408 KB |
Output is correct |
24 |
Correct |
10 ms |
14416 KB |
Output is correct |
25 |
Correct |
11 ms |
14488 KB |
Output is correct |
26 |
Correct |
10 ms |
14416 KB |
Output is correct |
27 |
Correct |
11 ms |
14420 KB |
Output is correct |
28 |
Correct |
9 ms |
14420 KB |
Output is correct |
29 |
Correct |
9 ms |
14548 KB |
Output is correct |
30 |
Correct |
25 ms |
15744 KB |
Output is correct |
31 |
Correct |
12 ms |
14952 KB |
Output is correct |
32 |
Correct |
33 ms |
20604 KB |
Output is correct |
33 |
Correct |
26 ms |
16428 KB |
Output is correct |
34 |
Correct |
43 ms |
24532 KB |
Output is correct |
35 |
Correct |
51 ms |
17368 KB |
Output is correct |
36 |
Correct |
40 ms |
16484 KB |
Output is correct |
37 |
Correct |
44 ms |
16412 KB |
Output is correct |
38 |
Correct |
33 ms |
16184 KB |
Output is correct |
39 |
Correct |
37 ms |
16196 KB |
Output is correct |
40 |
Correct |
49 ms |
26424 KB |
Output is correct |
41 |
Correct |
48 ms |
17680 KB |
Output is correct |
42 |
Correct |
43 ms |
17840 KB |
Output is correct |
43 |
Correct |
41 ms |
17260 KB |
Output is correct |
44 |
Correct |
52 ms |
18656 KB |
Output is correct |
45 |
Correct |
254 ms |
27996 KB |
Output is correct |
46 |
Correct |
13 ms |
17104 KB |
Output is correct |
47 |
Correct |
14 ms |
16996 KB |
Output is correct |
48 |
Correct |
351 ms |
41424 KB |
Output is correct |
49 |
Correct |
277 ms |
35436 KB |
Output is correct |
50 |
Correct |
611 ms |
87676 KB |
Output is correct |
51 |
Correct |
936 ms |
49016 KB |
Output is correct |
52 |
Correct |
659 ms |
35372 KB |
Output is correct |
53 |
Correct |
915 ms |
35620 KB |
Output is correct |
54 |
Correct |
1006 ms |
35464 KB |
Output is correct |
55 |
Correct |
1164 ms |
36216 KB |
Output is correct |
56 |
Correct |
1333 ms |
35632 KB |
Output is correct |
57 |
Correct |
439 ms |
29352 KB |
Output is correct |
58 |
Correct |
558 ms |
29528 KB |
Output is correct |
59 |
Correct |
498 ms |
29592 KB |
Output is correct |
60 |
Correct |
603 ms |
29472 KB |
Output is correct |
61 |
Correct |
773 ms |
29240 KB |
Output is correct |
62 |
Correct |
470 ms |
37232 KB |
Output is correct |
63 |
Correct |
386 ms |
37212 KB |
Output is correct |
64 |
Correct |
1135 ms |
66168 KB |
Output is correct |
65 |
Correct |
505 ms |
35052 KB |
Output is correct |
66 |
Correct |
407 ms |
30916 KB |
Output is correct |
67 |
Correct |
830 ms |
53000 KB |
Output is correct |
68 |
Correct |
194 ms |
26264 KB |
Output is correct |
69 |
Correct |
69 ms |
20208 KB |
Output is correct |
70 |
Correct |
808 ms |
47396 KB |
Output is correct |
71 |
Correct |
339 ms |
29072 KB |
Output is correct |
72 |
Correct |
228 ms |
25032 KB |
Output is correct |
73 |
Correct |
706 ms |
40616 KB |
Output is correct |
74 |
Correct |
1591 ms |
35480 KB |
Output is correct |
75 |
Correct |
1110 ms |
42832 KB |
Output is correct |
76 |
Correct |
1153 ms |
45988 KB |
Output is correct |