#include "game.h"
#include<bits/stdc++.h>
using namespace std;
int N,K,l[300100],r[300100];
#define F(i,j,K) for(int i = j; i <= K; i++)
#define FR(i,j) for(auto i: j)
vector<int> adj[300100],radj[300100];
void init(int N, int k) {
K = k;
F(i,0,K) l[i]=i,r[i]=i+1;
F(i,K+1,N) l[i]=0,r[i]=K+1;
F(i,0,N) adj[i].clear(),radj[i].clear();
}
bool calc(int u,int v){
if (r[u]<=l[v]) return 0;
if (l[u]>=r[v]) return 1;
if (l[u]==l[v]&&r[u]==r[v]) return 0;
if (r[v]<=(l[u]+r[u])/2){
r[u]=(l[u]+r[u])/2;
FR(i,radj[u])
if (calc(i,u))
return 1;
FR(i,adj[u])
if(calc(u,i)) return 1;
} else if (l[u]>=(l[v]+r[v])/2){
l[v]=(l[v]+r[v])/2;
FR(i,adj[v]) if (calc(v,i)) return 1;
FR(i,radj[v]) if (calc(i,v)) return 1;
}
return 0;
}
int add_teleporter(int u, int v) {
u++;
if (v>=K)
v++;
adj[u].push_back(v);
radj[v].push_back(u);
return calc(u,v);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
8 ms |
14408 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
7 ms |
14288 KB |
Output is correct |
6 |
Correct |
8 ms |
14408 KB |
Output is correct |
7 |
Correct |
9 ms |
14288 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
8 ms |
14408 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
7 ms |
14288 KB |
Output is correct |
6 |
Correct |
8 ms |
14408 KB |
Output is correct |
7 |
Correct |
9 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 |
7 ms |
14364 KB |
Output is correct |
11 |
Correct |
8 ms |
14288 KB |
Output is correct |
12 |
Correct |
7 ms |
14288 KB |
Output is correct |
13 |
Correct |
8 ms |
14288 KB |
Output is correct |
14 |
Correct |
9 ms |
14288 KB |
Output is correct |
15 |
Correct |
10 ms |
14288 KB |
Output is correct |
16 |
Correct |
8 ms |
14408 KB |
Output is correct |
17 |
Correct |
10 ms |
14288 KB |
Output is correct |
18 |
Correct |
8 ms |
14392 KB |
Output is correct |
19 |
Correct |
9 ms |
14340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
8 ms |
14408 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
7 ms |
14288 KB |
Output is correct |
6 |
Correct |
8 ms |
14408 KB |
Output is correct |
7 |
Correct |
9 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 |
7 ms |
14364 KB |
Output is correct |
11 |
Correct |
8 ms |
14288 KB |
Output is correct |
12 |
Correct |
7 ms |
14288 KB |
Output is correct |
13 |
Correct |
8 ms |
14288 KB |
Output is correct |
14 |
Correct |
9 ms |
14288 KB |
Output is correct |
15 |
Correct |
10 ms |
14288 KB |
Output is correct |
16 |
Correct |
8 ms |
14408 KB |
Output is correct |
17 |
Correct |
10 ms |
14288 KB |
Output is correct |
18 |
Correct |
8 ms |
14392 KB |
Output is correct |
19 |
Correct |
9 ms |
14340 KB |
Output is correct |
20 |
Correct |
8 ms |
14416 KB |
Output is correct |
21 |
Correct |
8 ms |
14416 KB |
Output is correct |
22 |
Correct |
9 ms |
14416 KB |
Output is correct |
23 |
Correct |
8 ms |
14416 KB |
Output is correct |
24 |
Correct |
9 ms |
14416 KB |
Output is correct |
25 |
Correct |
11 ms |
14492 KB |
Output is correct |
26 |
Correct |
10 ms |
14416 KB |
Output is correct |
27 |
Correct |
10 ms |
14416 KB |
Output is correct |
28 |
Correct |
11 ms |
14416 KB |
Output is correct |
29 |
Correct |
10 ms |
14504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
8 ms |
14408 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
7 ms |
14288 KB |
Output is correct |
6 |
Correct |
8 ms |
14408 KB |
Output is correct |
7 |
Correct |
9 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 |
7 ms |
14364 KB |
Output is correct |
11 |
Correct |
8 ms |
14288 KB |
Output is correct |
12 |
Correct |
7 ms |
14288 KB |
Output is correct |
13 |
Correct |
8 ms |
14288 KB |
Output is correct |
14 |
Correct |
9 ms |
14288 KB |
Output is correct |
15 |
Correct |
10 ms |
14288 KB |
Output is correct |
16 |
Correct |
8 ms |
14408 KB |
Output is correct |
17 |
Correct |
10 ms |
14288 KB |
Output is correct |
18 |
Correct |
8 ms |
14392 KB |
Output is correct |
19 |
Correct |
9 ms |
14340 KB |
Output is correct |
20 |
Correct |
8 ms |
14416 KB |
Output is correct |
21 |
Correct |
8 ms |
14416 KB |
Output is correct |
22 |
Correct |
9 ms |
14416 KB |
Output is correct |
23 |
Correct |
8 ms |
14416 KB |
Output is correct |
24 |
Correct |
9 ms |
14416 KB |
Output is correct |
25 |
Correct |
11 ms |
14492 KB |
Output is correct |
26 |
Correct |
10 ms |
14416 KB |
Output is correct |
27 |
Correct |
10 ms |
14416 KB |
Output is correct |
28 |
Correct |
11 ms |
14416 KB |
Output is correct |
29 |
Correct |
10 ms |
14504 KB |
Output is correct |
30 |
Correct |
22 ms |
15696 KB |
Output is correct |
31 |
Correct |
11 ms |
14980 KB |
Output is correct |
32 |
Correct |
30 ms |
17744 KB |
Output is correct |
33 |
Correct |
23 ms |
16444 KB |
Output is correct |
34 |
Correct |
45 ms |
19144 KB |
Output is correct |
35 |
Correct |
53 ms |
17372 KB |
Output is correct |
36 |
Correct |
41 ms |
16476 KB |
Output is correct |
37 |
Correct |
40 ms |
16392 KB |
Output is correct |
38 |
Correct |
31 ms |
16236 KB |
Output is correct |
39 |
Correct |
43 ms |
16200 KB |
Output is correct |
40 |
Correct |
52 ms |
19068 KB |
Output is correct |
41 |
Correct |
49 ms |
17728 KB |
Output is correct |
42 |
Correct |
46 ms |
16620 KB |
Output is correct |
43 |
Correct |
52 ms |
17204 KB |
Output is correct |
44 |
Correct |
47 ms |
17496 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
8 ms |
14408 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
7 ms |
14288 KB |
Output is correct |
6 |
Correct |
8 ms |
14408 KB |
Output is correct |
7 |
Correct |
9 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 |
7 ms |
14364 KB |
Output is correct |
11 |
Correct |
8 ms |
14288 KB |
Output is correct |
12 |
Correct |
7 ms |
14288 KB |
Output is correct |
13 |
Correct |
8 ms |
14288 KB |
Output is correct |
14 |
Correct |
9 ms |
14288 KB |
Output is correct |
15 |
Correct |
10 ms |
14288 KB |
Output is correct |
16 |
Correct |
8 ms |
14408 KB |
Output is correct |
17 |
Correct |
10 ms |
14288 KB |
Output is correct |
18 |
Correct |
8 ms |
14392 KB |
Output is correct |
19 |
Correct |
9 ms |
14340 KB |
Output is correct |
20 |
Correct |
8 ms |
14416 KB |
Output is correct |
21 |
Correct |
8 ms |
14416 KB |
Output is correct |
22 |
Correct |
9 ms |
14416 KB |
Output is correct |
23 |
Correct |
8 ms |
14416 KB |
Output is correct |
24 |
Correct |
9 ms |
14416 KB |
Output is correct |
25 |
Correct |
11 ms |
14492 KB |
Output is correct |
26 |
Correct |
10 ms |
14416 KB |
Output is correct |
27 |
Correct |
10 ms |
14416 KB |
Output is correct |
28 |
Correct |
11 ms |
14416 KB |
Output is correct |
29 |
Correct |
10 ms |
14504 KB |
Output is correct |
30 |
Correct |
22 ms |
15696 KB |
Output is correct |
31 |
Correct |
11 ms |
14980 KB |
Output is correct |
32 |
Correct |
30 ms |
17744 KB |
Output is correct |
33 |
Correct |
23 ms |
16444 KB |
Output is correct |
34 |
Correct |
45 ms |
19144 KB |
Output is correct |
35 |
Correct |
53 ms |
17372 KB |
Output is correct |
36 |
Correct |
41 ms |
16476 KB |
Output is correct |
37 |
Correct |
40 ms |
16392 KB |
Output is correct |
38 |
Correct |
31 ms |
16236 KB |
Output is correct |
39 |
Correct |
43 ms |
16200 KB |
Output is correct |
40 |
Correct |
52 ms |
19068 KB |
Output is correct |
41 |
Correct |
49 ms |
17728 KB |
Output is correct |
42 |
Correct |
46 ms |
16620 KB |
Output is correct |
43 |
Correct |
52 ms |
17204 KB |
Output is correct |
44 |
Correct |
47 ms |
17496 KB |
Output is correct |
45 |
Correct |
282 ms |
28072 KB |
Output is correct |
46 |
Correct |
14 ms |
17104 KB |
Output is correct |
47 |
Correct |
15 ms |
17104 KB |
Output is correct |
48 |
Correct |
321 ms |
41520 KB |
Output is correct |
49 |
Correct |
273 ms |
35500 KB |
Output is correct |
50 |
Correct |
804 ms |
45488 KB |
Output is correct |
51 |
Correct |
973 ms |
42132 KB |
Output is correct |
52 |
Correct |
660 ms |
35392 KB |
Output is correct |
53 |
Correct |
831 ms |
35588 KB |
Output is correct |
54 |
Correct |
1002 ms |
35304 KB |
Output is correct |
55 |
Correct |
1236 ms |
36008 KB |
Output is correct |
56 |
Correct |
1385 ms |
35628 KB |
Output is correct |
57 |
Correct |
465 ms |
29404 KB |
Output is correct |
58 |
Correct |
538 ms |
29560 KB |
Output is correct |
59 |
Correct |
554 ms |
29544 KB |
Output is correct |
60 |
Correct |
568 ms |
29444 KB |
Output is correct |
61 |
Correct |
712 ms |
29144 KB |
Output is correct |
62 |
Correct |
473 ms |
37104 KB |
Output is correct |
63 |
Correct |
421 ms |
33772 KB |
Output is correct |
64 |
Correct |
1187 ms |
55888 KB |
Output is correct |
65 |
Correct |
589 ms |
35012 KB |
Output is correct |
66 |
Correct |
503 ms |
30920 KB |
Output is correct |
67 |
Correct |
943 ms |
39864 KB |
Output is correct |
68 |
Correct |
248 ms |
26364 KB |
Output is correct |
69 |
Correct |
56 ms |
20152 KB |
Output is correct |
70 |
Correct |
928 ms |
38596 KB |
Output is correct |
71 |
Correct |
336 ms |
29032 KB |
Output is correct |
72 |
Correct |
233 ms |
24904 KB |
Output is correct |
73 |
Correct |
859 ms |
40672 KB |
Output is correct |
74 |
Correct |
1627 ms |
35608 KB |
Output is correct |
75 |
Correct |
1245 ms |
42984 KB |
Output is correct |
76 |
Correct |
1219 ms |
45996 KB |
Output is correct |