// hola soy Dember :D
// 31/03/2024
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define F first
#define S second
#define Z size()
#define pb push_back
#define bp pop_back
#define fo(x,y,z) for(ll x=y; x<=z; x++)
#define of(x,y,z) for(ll x=y; x>=z; x--)
#define all(n) n.begin(), n.end()
#define arr(x,y,z) x+y, x+y+z
#define dd double
using namespace std;
const ll MN=300005;
ll n, k, xd, l[MN], r[MN], sevennationarmy[MN];
vector<ll> x[MN], y[MN];
void dfs(ll u){
if(xd)return;
if(r[u]<=l[u]){xd=1; return;}
if (sevennationarmy[u]>__lg(l[u]^r[u]))sevennationarmy[u]=__lg(l[u]^r[u]);
else return;
for(ll v:x[u])l[v]=max(l[v], l[u]), dfs(v);
for(ll v:y[u])r[v]=min(r[v], r[u]), dfs(v);
}
void init(int N, int K){
n=N, k=K;
fo(i,0,k-1)l[i]=i, r[i]=i+1;
fo(i,k,n-1)l[i]=-1, r[i]=k;
fo(i,0,n-1)sevennationarmy[i]=__lg(l[i]^r[i]);
return;
}
int add_teleporter(int u, int v){
x[u].pb(v), y[v].pb(u);
l[v]=max(l[v], max(l[u], ((u<k)?u:-1)+0ll)), dfs(v);
r[u]=min(r[u], min(r[v], ((v<k)?v:k) +0ll)), dfs(u);
return xd;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
14936 KB |
Output is correct |
2 |
Correct |
5 ms |
14948 KB |
Output is correct |
3 |
Correct |
5 ms |
15192 KB |
Output is correct |
4 |
Correct |
5 ms |
14936 KB |
Output is correct |
5 |
Correct |
7 ms |
14424 KB |
Output is correct |
6 |
Correct |
6 ms |
14424 KB |
Output is correct |
7 |
Correct |
5 ms |
14424 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
14936 KB |
Output is correct |
2 |
Correct |
5 ms |
14948 KB |
Output is correct |
3 |
Correct |
5 ms |
15192 KB |
Output is correct |
4 |
Correct |
5 ms |
14936 KB |
Output is correct |
5 |
Correct |
7 ms |
14424 KB |
Output is correct |
6 |
Correct |
6 ms |
14424 KB |
Output is correct |
7 |
Correct |
5 ms |
14424 KB |
Output is correct |
8 |
Correct |
6 ms |
14420 KB |
Output is correct |
9 |
Correct |
5 ms |
14936 KB |
Output is correct |
10 |
Correct |
4 ms |
14880 KB |
Output is correct |
11 |
Correct |
6 ms |
14424 KB |
Output is correct |
12 |
Correct |
5 ms |
14424 KB |
Output is correct |
13 |
Correct |
8 ms |
14424 KB |
Output is correct |
14 |
Correct |
6 ms |
14424 KB |
Output is correct |
15 |
Correct |
6 ms |
14424 KB |
Output is correct |
16 |
Correct |
8 ms |
14424 KB |
Output is correct |
17 |
Correct |
5 ms |
14936 KB |
Output is correct |
18 |
Correct |
8 ms |
14336 KB |
Output is correct |
19 |
Correct |
6 ms |
14424 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
14936 KB |
Output is correct |
2 |
Correct |
5 ms |
14948 KB |
Output is correct |
3 |
Correct |
5 ms |
15192 KB |
Output is correct |
4 |
Correct |
5 ms |
14936 KB |
Output is correct |
5 |
Correct |
7 ms |
14424 KB |
Output is correct |
6 |
Correct |
6 ms |
14424 KB |
Output is correct |
7 |
Correct |
5 ms |
14424 KB |
Output is correct |
8 |
Correct |
6 ms |
14420 KB |
Output is correct |
9 |
Correct |
5 ms |
14936 KB |
Output is correct |
10 |
Correct |
4 ms |
14880 KB |
Output is correct |
11 |
Correct |
6 ms |
14424 KB |
Output is correct |
12 |
Correct |
5 ms |
14424 KB |
Output is correct |
13 |
Correct |
8 ms |
14424 KB |
Output is correct |
14 |
Correct |
6 ms |
14424 KB |
Output is correct |
15 |
Correct |
6 ms |
14424 KB |
Output is correct |
16 |
Correct |
8 ms |
14424 KB |
Output is correct |
17 |
Correct |
5 ms |
14936 KB |
Output is correct |
18 |
Correct |
8 ms |
14336 KB |
Output is correct |
19 |
Correct |
6 ms |
14424 KB |
Output is correct |
20 |
Correct |
7 ms |
14424 KB |
Output is correct |
21 |
Correct |
7 ms |
14396 KB |
Output is correct |
22 |
Correct |
6 ms |
14424 KB |
Output is correct |
23 |
Correct |
7 ms |
14464 KB |
Output is correct |
24 |
Correct |
4 ms |
15188 KB |
Output is correct |
25 |
Correct |
6 ms |
14936 KB |
Output is correct |
26 |
Correct |
8 ms |
14776 KB |
Output is correct |
27 |
Correct |
6 ms |
15192 KB |
Output is correct |
28 |
Correct |
5 ms |
14936 KB |
Output is correct |
29 |
Correct |
8 ms |
14680 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
14936 KB |
Output is correct |
2 |
Correct |
5 ms |
14948 KB |
Output is correct |
3 |
Correct |
5 ms |
15192 KB |
Output is correct |
4 |
Correct |
5 ms |
14936 KB |
Output is correct |
5 |
Correct |
7 ms |
14424 KB |
Output is correct |
6 |
Correct |
6 ms |
14424 KB |
Output is correct |
7 |
Correct |
5 ms |
14424 KB |
Output is correct |
8 |
Correct |
6 ms |
14420 KB |
Output is correct |
9 |
Correct |
5 ms |
14936 KB |
Output is correct |
10 |
Correct |
4 ms |
14880 KB |
Output is correct |
11 |
Correct |
6 ms |
14424 KB |
Output is correct |
12 |
Correct |
5 ms |
14424 KB |
Output is correct |
13 |
Correct |
8 ms |
14424 KB |
Output is correct |
14 |
Correct |
6 ms |
14424 KB |
Output is correct |
15 |
Correct |
6 ms |
14424 KB |
Output is correct |
16 |
Correct |
8 ms |
14424 KB |
Output is correct |
17 |
Correct |
5 ms |
14936 KB |
Output is correct |
18 |
Correct |
8 ms |
14336 KB |
Output is correct |
19 |
Correct |
6 ms |
14424 KB |
Output is correct |
20 |
Correct |
7 ms |
14424 KB |
Output is correct |
21 |
Correct |
7 ms |
14396 KB |
Output is correct |
22 |
Correct |
6 ms |
14424 KB |
Output is correct |
23 |
Correct |
7 ms |
14464 KB |
Output is correct |
24 |
Correct |
4 ms |
15188 KB |
Output is correct |
25 |
Correct |
6 ms |
14936 KB |
Output is correct |
26 |
Correct |
8 ms |
14776 KB |
Output is correct |
27 |
Correct |
6 ms |
15192 KB |
Output is correct |
28 |
Correct |
5 ms |
14936 KB |
Output is correct |
29 |
Correct |
8 ms |
14680 KB |
Output is correct |
30 |
Correct |
22 ms |
16776 KB |
Output is correct |
31 |
Correct |
10 ms |
15960 KB |
Output is correct |
32 |
Correct |
23 ms |
17448 KB |
Output is correct |
33 |
Correct |
25 ms |
17476 KB |
Output is correct |
34 |
Correct |
36 ms |
21472 KB |
Output is correct |
35 |
Correct |
30 ms |
18780 KB |
Output is correct |
36 |
Correct |
35 ms |
17592 KB |
Output is correct |
37 |
Correct |
42 ms |
17416 KB |
Output is correct |
38 |
Correct |
36 ms |
17416 KB |
Output is correct |
39 |
Correct |
32 ms |
17536 KB |
Output is correct |
40 |
Correct |
42 ms |
21244 KB |
Output is correct |
41 |
Correct |
38 ms |
18088 KB |
Output is correct |
42 |
Correct |
44 ms |
18128 KB |
Output is correct |
43 |
Correct |
47 ms |
18908 KB |
Output is correct |
44 |
Correct |
47 ms |
19116 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
14936 KB |
Output is correct |
2 |
Correct |
5 ms |
14948 KB |
Output is correct |
3 |
Correct |
5 ms |
15192 KB |
Output is correct |
4 |
Correct |
5 ms |
14936 KB |
Output is correct |
5 |
Correct |
7 ms |
14424 KB |
Output is correct |
6 |
Correct |
6 ms |
14424 KB |
Output is correct |
7 |
Correct |
5 ms |
14424 KB |
Output is correct |
8 |
Correct |
6 ms |
14420 KB |
Output is correct |
9 |
Correct |
5 ms |
14936 KB |
Output is correct |
10 |
Correct |
4 ms |
14880 KB |
Output is correct |
11 |
Correct |
6 ms |
14424 KB |
Output is correct |
12 |
Correct |
5 ms |
14424 KB |
Output is correct |
13 |
Correct |
8 ms |
14424 KB |
Output is correct |
14 |
Correct |
6 ms |
14424 KB |
Output is correct |
15 |
Correct |
6 ms |
14424 KB |
Output is correct |
16 |
Correct |
8 ms |
14424 KB |
Output is correct |
17 |
Correct |
5 ms |
14936 KB |
Output is correct |
18 |
Correct |
8 ms |
14336 KB |
Output is correct |
19 |
Correct |
6 ms |
14424 KB |
Output is correct |
20 |
Correct |
7 ms |
14424 KB |
Output is correct |
21 |
Correct |
7 ms |
14396 KB |
Output is correct |
22 |
Correct |
6 ms |
14424 KB |
Output is correct |
23 |
Correct |
7 ms |
14464 KB |
Output is correct |
24 |
Correct |
4 ms |
15188 KB |
Output is correct |
25 |
Correct |
6 ms |
14936 KB |
Output is correct |
26 |
Correct |
8 ms |
14776 KB |
Output is correct |
27 |
Correct |
6 ms |
15192 KB |
Output is correct |
28 |
Correct |
5 ms |
14936 KB |
Output is correct |
29 |
Correct |
8 ms |
14680 KB |
Output is correct |
30 |
Correct |
22 ms |
16776 KB |
Output is correct |
31 |
Correct |
10 ms |
15960 KB |
Output is correct |
32 |
Correct |
23 ms |
17448 KB |
Output is correct |
33 |
Correct |
25 ms |
17476 KB |
Output is correct |
34 |
Correct |
36 ms |
21472 KB |
Output is correct |
35 |
Correct |
30 ms |
18780 KB |
Output is correct |
36 |
Correct |
35 ms |
17592 KB |
Output is correct |
37 |
Correct |
42 ms |
17416 KB |
Output is correct |
38 |
Correct |
36 ms |
17416 KB |
Output is correct |
39 |
Correct |
32 ms |
17536 KB |
Output is correct |
40 |
Correct |
42 ms |
21244 KB |
Output is correct |
41 |
Correct |
38 ms |
18088 KB |
Output is correct |
42 |
Correct |
44 ms |
18128 KB |
Output is correct |
43 |
Correct |
47 ms |
18908 KB |
Output is correct |
44 |
Correct |
47 ms |
19116 KB |
Output is correct |
45 |
Correct |
262 ms |
33816 KB |
Output is correct |
46 |
Correct |
15 ms |
22108 KB |
Output is correct |
47 |
Correct |
15 ms |
22292 KB |
Output is correct |
48 |
Correct |
400 ms |
48416 KB |
Output is correct |
49 |
Correct |
287 ms |
40588 KB |
Output is correct |
50 |
Correct |
816 ms |
55648 KB |
Output is correct |
51 |
Correct |
936 ms |
51280 KB |
Output is correct |
52 |
Correct |
660 ms |
40784 KB |
Output is correct |
53 |
Correct |
814 ms |
41472 KB |
Output is correct |
54 |
Correct |
933 ms |
41084 KB |
Output is correct |
55 |
Correct |
1271 ms |
41568 KB |
Output is correct |
56 |
Correct |
1335 ms |
41408 KB |
Output is correct |
57 |
Correct |
480 ms |
37132 KB |
Output is correct |
58 |
Correct |
528 ms |
36924 KB |
Output is correct |
59 |
Correct |
508 ms |
37224 KB |
Output is correct |
60 |
Correct |
517 ms |
37108 KB |
Output is correct |
61 |
Correct |
640 ms |
36172 KB |
Output is correct |
62 |
Correct |
634 ms |
44984 KB |
Output is correct |
63 |
Correct |
563 ms |
41460 KB |
Output is correct |
64 |
Correct |
1523 ms |
69700 KB |
Output is correct |
65 |
Correct |
558 ms |
41952 KB |
Output is correct |
66 |
Correct |
477 ms |
37920 KB |
Output is correct |
67 |
Correct |
846 ms |
47616 KB |
Output is correct |
68 |
Correct |
211 ms |
31892 KB |
Output is correct |
69 |
Correct |
70 ms |
25756 KB |
Output is correct |
70 |
Correct |
813 ms |
48596 KB |
Output is correct |
71 |
Correct |
402 ms |
35912 KB |
Output is correct |
72 |
Correct |
288 ms |
31580 KB |
Output is correct |
73 |
Correct |
706 ms |
45724 KB |
Output is correct |
74 |
Correct |
1563 ms |
42004 KB |
Output is correct |
75 |
Correct |
1322 ms |
51420 KB |
Output is correct |
76 |
Correct |
1329 ms |
61220 KB |
Output is correct |