#include "game.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5+5;
int n,k,f,l[maxn],r[maxn],cc[maxn];
vector<int> edge[maxn],rev_edge[maxn];
void init(int N, int K) {
n=N;k=K;
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+1;
for(int i=0;i<n;i++) cc[i]=__lg(l[i]^r[i]);
}
void update(int u){
if(f) return;
if(r[u]<=l[u]) return void(f=1);
int nw=__lg(l[u]^r[u]);
if(nw==cc[u]) return;
cc[u]=nw;
for(int v:edge[u]){
if(l[v]<l[u]) l[v]=l[u],update(v);
}
for(int v:rev_edge[u]){
if(r[v]>r[u]) r[v]=r[u],update(v);
}
}
int add_teleporter(int u, int v) {
if(v<=u && u<k) return 1;
if(u==v) return 0;
edge[u].push_back(v);
rev_edge[v].push_back(u);
int x=(u<k?max(u+1,l[u]):l[u]);
if(l[v]<x) l[v]=x,update(v);
if(r[u]>r[v]) r[u]=r[v],update(u);
return f;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
16984 KB |
Output is correct |
2 |
Correct |
3 ms |
16984 KB |
Output is correct |
3 |
Correct |
4 ms |
17240 KB |
Output is correct |
4 |
Correct |
4 ms |
16980 KB |
Output is correct |
5 |
Correct |
3 ms |
16984 KB |
Output is correct |
6 |
Correct |
3 ms |
16984 KB |
Output is correct |
7 |
Correct |
3 ms |
16984 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
16984 KB |
Output is correct |
2 |
Correct |
3 ms |
16984 KB |
Output is correct |
3 |
Correct |
4 ms |
17240 KB |
Output is correct |
4 |
Correct |
4 ms |
16980 KB |
Output is correct |
5 |
Correct |
3 ms |
16984 KB |
Output is correct |
6 |
Correct |
3 ms |
16984 KB |
Output is correct |
7 |
Correct |
3 ms |
16984 KB |
Output is correct |
8 |
Correct |
4 ms |
16984 KB |
Output is correct |
9 |
Correct |
3 ms |
16828 KB |
Output is correct |
10 |
Correct |
4 ms |
16984 KB |
Output is correct |
11 |
Correct |
4 ms |
17236 KB |
Output is correct |
12 |
Correct |
3 ms |
16984 KB |
Output is correct |
13 |
Correct |
4 ms |
16984 KB |
Output is correct |
14 |
Correct |
3 ms |
16980 KB |
Output is correct |
15 |
Correct |
3 ms |
16984 KB |
Output is correct |
16 |
Correct |
3 ms |
16996 KB |
Output is correct |
17 |
Correct |
3 ms |
16996 KB |
Output is correct |
18 |
Correct |
3 ms |
16996 KB |
Output is correct |
19 |
Correct |
3 ms |
16996 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
16984 KB |
Output is correct |
2 |
Correct |
3 ms |
16984 KB |
Output is correct |
3 |
Correct |
4 ms |
17240 KB |
Output is correct |
4 |
Correct |
4 ms |
16980 KB |
Output is correct |
5 |
Correct |
3 ms |
16984 KB |
Output is correct |
6 |
Correct |
3 ms |
16984 KB |
Output is correct |
7 |
Correct |
3 ms |
16984 KB |
Output is correct |
8 |
Correct |
4 ms |
16984 KB |
Output is correct |
9 |
Correct |
3 ms |
16828 KB |
Output is correct |
10 |
Correct |
4 ms |
16984 KB |
Output is correct |
11 |
Correct |
4 ms |
17236 KB |
Output is correct |
12 |
Correct |
3 ms |
16984 KB |
Output is correct |
13 |
Correct |
4 ms |
16984 KB |
Output is correct |
14 |
Correct |
3 ms |
16980 KB |
Output is correct |
15 |
Correct |
3 ms |
16984 KB |
Output is correct |
16 |
Correct |
3 ms |
16996 KB |
Output is correct |
17 |
Correct |
3 ms |
16996 KB |
Output is correct |
18 |
Correct |
3 ms |
16996 KB |
Output is correct |
19 |
Correct |
3 ms |
16996 KB |
Output is correct |
20 |
Correct |
4 ms |
17504 KB |
Output is correct |
21 |
Correct |
3 ms |
16996 KB |
Output is correct |
22 |
Correct |
4 ms |
16996 KB |
Output is correct |
23 |
Correct |
4 ms |
17508 KB |
Output is correct |
24 |
Correct |
5 ms |
17252 KB |
Output is correct |
25 |
Correct |
5 ms |
16984 KB |
Output is correct |
26 |
Correct |
5 ms |
16996 KB |
Output is correct |
27 |
Correct |
6 ms |
17252 KB |
Output is correct |
28 |
Correct |
4 ms |
17500 KB |
Output is correct |
29 |
Correct |
6 ms |
17344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
16984 KB |
Output is correct |
2 |
Correct |
3 ms |
16984 KB |
Output is correct |
3 |
Correct |
4 ms |
17240 KB |
Output is correct |
4 |
Correct |
4 ms |
16980 KB |
Output is correct |
5 |
Correct |
3 ms |
16984 KB |
Output is correct |
6 |
Correct |
3 ms |
16984 KB |
Output is correct |
7 |
Correct |
3 ms |
16984 KB |
Output is correct |
8 |
Correct |
4 ms |
16984 KB |
Output is correct |
9 |
Correct |
3 ms |
16828 KB |
Output is correct |
10 |
Correct |
4 ms |
16984 KB |
Output is correct |
11 |
Correct |
4 ms |
17236 KB |
Output is correct |
12 |
Correct |
3 ms |
16984 KB |
Output is correct |
13 |
Correct |
4 ms |
16984 KB |
Output is correct |
14 |
Correct |
3 ms |
16980 KB |
Output is correct |
15 |
Correct |
3 ms |
16984 KB |
Output is correct |
16 |
Correct |
3 ms |
16996 KB |
Output is correct |
17 |
Correct |
3 ms |
16996 KB |
Output is correct |
18 |
Correct |
3 ms |
16996 KB |
Output is correct |
19 |
Correct |
3 ms |
16996 KB |
Output is correct |
20 |
Correct |
4 ms |
17504 KB |
Output is correct |
21 |
Correct |
3 ms |
16996 KB |
Output is correct |
22 |
Correct |
4 ms |
16996 KB |
Output is correct |
23 |
Correct |
4 ms |
17508 KB |
Output is correct |
24 |
Correct |
5 ms |
17252 KB |
Output is correct |
25 |
Correct |
5 ms |
16984 KB |
Output is correct |
26 |
Correct |
5 ms |
16996 KB |
Output is correct |
27 |
Correct |
6 ms |
17252 KB |
Output is correct |
28 |
Correct |
4 ms |
17500 KB |
Output is correct |
29 |
Correct |
6 ms |
17344 KB |
Output is correct |
30 |
Correct |
18 ms |
18532 KB |
Output is correct |
31 |
Correct |
8 ms |
17700 KB |
Output is correct |
32 |
Correct |
19 ms |
20128 KB |
Output is correct |
33 |
Correct |
21 ms |
18840 KB |
Output is correct |
34 |
Correct |
24 ms |
22924 KB |
Output is correct |
35 |
Correct |
32 ms |
20480 KB |
Output is correct |
36 |
Correct |
30 ms |
19588 KB |
Output is correct |
37 |
Correct |
26 ms |
18776 KB |
Output is correct |
38 |
Correct |
28 ms |
19288 KB |
Output is correct |
39 |
Correct |
29 ms |
18956 KB |
Output is correct |
40 |
Correct |
32 ms |
22284 KB |
Output is correct |
41 |
Correct |
27 ms |
20304 KB |
Output is correct |
42 |
Correct |
36 ms |
19540 KB |
Output is correct |
43 |
Correct |
32 ms |
20572 KB |
Output is correct |
44 |
Correct |
27 ms |
19688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
16984 KB |
Output is correct |
2 |
Correct |
3 ms |
16984 KB |
Output is correct |
3 |
Correct |
4 ms |
17240 KB |
Output is correct |
4 |
Correct |
4 ms |
16980 KB |
Output is correct |
5 |
Correct |
3 ms |
16984 KB |
Output is correct |
6 |
Correct |
3 ms |
16984 KB |
Output is correct |
7 |
Correct |
3 ms |
16984 KB |
Output is correct |
8 |
Correct |
4 ms |
16984 KB |
Output is correct |
9 |
Correct |
3 ms |
16828 KB |
Output is correct |
10 |
Correct |
4 ms |
16984 KB |
Output is correct |
11 |
Correct |
4 ms |
17236 KB |
Output is correct |
12 |
Correct |
3 ms |
16984 KB |
Output is correct |
13 |
Correct |
4 ms |
16984 KB |
Output is correct |
14 |
Correct |
3 ms |
16980 KB |
Output is correct |
15 |
Correct |
3 ms |
16984 KB |
Output is correct |
16 |
Correct |
3 ms |
16996 KB |
Output is correct |
17 |
Correct |
3 ms |
16996 KB |
Output is correct |
18 |
Correct |
3 ms |
16996 KB |
Output is correct |
19 |
Correct |
3 ms |
16996 KB |
Output is correct |
20 |
Correct |
4 ms |
17504 KB |
Output is correct |
21 |
Correct |
3 ms |
16996 KB |
Output is correct |
22 |
Correct |
4 ms |
16996 KB |
Output is correct |
23 |
Correct |
4 ms |
17508 KB |
Output is correct |
24 |
Correct |
5 ms |
17252 KB |
Output is correct |
25 |
Correct |
5 ms |
16984 KB |
Output is correct |
26 |
Correct |
5 ms |
16996 KB |
Output is correct |
27 |
Correct |
6 ms |
17252 KB |
Output is correct |
28 |
Correct |
4 ms |
17500 KB |
Output is correct |
29 |
Correct |
6 ms |
17344 KB |
Output is correct |
30 |
Correct |
18 ms |
18532 KB |
Output is correct |
31 |
Correct |
8 ms |
17700 KB |
Output is correct |
32 |
Correct |
19 ms |
20128 KB |
Output is correct |
33 |
Correct |
21 ms |
18840 KB |
Output is correct |
34 |
Correct |
24 ms |
22924 KB |
Output is correct |
35 |
Correct |
32 ms |
20480 KB |
Output is correct |
36 |
Correct |
30 ms |
19588 KB |
Output is correct |
37 |
Correct |
26 ms |
18776 KB |
Output is correct |
38 |
Correct |
28 ms |
19288 KB |
Output is correct |
39 |
Correct |
29 ms |
18956 KB |
Output is correct |
40 |
Correct |
32 ms |
22284 KB |
Output is correct |
41 |
Correct |
27 ms |
20304 KB |
Output is correct |
42 |
Correct |
36 ms |
19540 KB |
Output is correct |
43 |
Correct |
32 ms |
20572 KB |
Output is correct |
44 |
Correct |
27 ms |
19688 KB |
Output is correct |
45 |
Correct |
192 ms |
29984 KB |
Output is correct |
46 |
Correct |
10 ms |
18776 KB |
Output is correct |
47 |
Correct |
10 ms |
18520 KB |
Output is correct |
48 |
Correct |
249 ms |
46604 KB |
Output is correct |
49 |
Correct |
211 ms |
37588 KB |
Output is correct |
50 |
Correct |
479 ms |
51596 KB |
Output is correct |
51 |
Correct |
750 ms |
46656 KB |
Output is correct |
52 |
Correct |
389 ms |
36836 KB |
Output is correct |
53 |
Correct |
566 ms |
36880 KB |
Output is correct |
54 |
Correct |
501 ms |
37028 KB |
Output is correct |
55 |
Correct |
826 ms |
37180 KB |
Output is correct |
56 |
Correct |
853 ms |
37272 KB |
Output is correct |
57 |
Correct |
326 ms |
31748 KB |
Output is correct |
58 |
Correct |
324 ms |
31308 KB |
Output is correct |
59 |
Correct |
324 ms |
30940 KB |
Output is correct |
60 |
Correct |
328 ms |
31216 KB |
Output is correct |
61 |
Correct |
357 ms |
30692 KB |
Output is correct |
62 |
Correct |
331 ms |
41136 KB |
Output is correct |
63 |
Correct |
303 ms |
37880 KB |
Output is correct |
64 |
Correct |
952 ms |
64028 KB |
Output is correct |
65 |
Correct |
374 ms |
37752 KB |
Output is correct |
66 |
Correct |
352 ms |
33824 KB |
Output is correct |
67 |
Correct |
610 ms |
42956 KB |
Output is correct |
68 |
Correct |
145 ms |
27972 KB |
Output is correct |
69 |
Correct |
35 ms |
21600 KB |
Output is correct |
70 |
Correct |
613 ms |
42304 KB |
Output is correct |
71 |
Correct |
253 ms |
30888 KB |
Output is correct |
72 |
Correct |
181 ms |
26652 KB |
Output is correct |
73 |
Correct |
506 ms |
40016 KB |
Output is correct |
74 |
Correct |
861 ms |
36852 KB |
Output is correct |
75 |
Correct |
934 ms |
46940 KB |
Output is correct |
76 |
Correct |
814 ms |
45736 KB |
Output is correct |