#include "game.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
const int N = (int)3e5 + 10;
vector<int> T[N];
vector<int> R[N];
pii G[N];
pii layer[N];
void init(int n, int k) {
for(int i = 1 ; i <= n; i ++ ){
if(i <= k){
G[i] = mp(i, i);
}
else{
G[i] = mp(0, k + 1);
}
layer[i] = mp(0, k + 1);
}
}
int explore(int u, int v){
if(G[u].fi >= G[v].se){
return 1;
}
if(G[u].fi > G[v].fi){
G[v].fi = G[u].fi;
}
if(G[v].se < G[u].se){
G[u].se = G[v].se;
}
if((layer[u].fi < layer[u].se) && (layer[u].fi + layer[u].se) / 2 >= G[u].se){
layer[u].se = (layer[u].fi + layer[u].se) / 2;
for(auto x : T[u]){
if(explore(u, x)) return 1;
}
for(auto x : R[u]){
if(explore(x, u)) return 1;
}
}
else if((layer[u].fi < layer[u].se) && (layer[u].fi + layer[u].se) / 2 < G[u].fi){
layer[u].fi = (layer[u].fi + layer[u].se) / 2 + 1;
for(auto x : T[u]){
if(explore(u, x)) return 1;
}
for(auto x : R[u]){
if(explore(x, u)) return 1;
}
}
else if((layer[v].fi < layer[v].se) && (layer[v].fi + layer[v].se) / 2 >= G[v].se){
layer[v].se = (layer[v].fi + layer[v].se) / 2;
for(auto x : T[v]){
if(explore(v, x)) return 1;
}
for(auto x : R[v]){
if(explore(x, v)) return 1;
}
}
else if((layer[v].fi < layer[v].se) && (layer[v].fi + layer[v].se) / 2 < G[v].fi){
layer[v].fi = (layer[v].fi + layer[v].se) / 2 + 1;
for(auto x : T[v]){
if(explore(v, x)) return 1;
}
for(auto x : R[v]){
if(explore(x, v)) return 1;
}
}
return 0;
}
int add_teleporter(int u, int v) {
u ++ ;
v ++ ;
T[u].push_back(v);
R[v].push_back(u);
return explore(u, v);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14324 KB |
Output is correct |
3 |
Correct |
8 ms |
14288 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
7 ms |
14392 KB |
Output is correct |
6 |
Correct |
7 ms |
14288 KB |
Output is correct |
7 |
Correct |
8 ms |
14288 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14324 KB |
Output is correct |
3 |
Correct |
8 ms |
14288 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
7 ms |
14392 KB |
Output is correct |
6 |
Correct |
7 ms |
14288 KB |
Output is correct |
7 |
Correct |
8 ms |
14288 KB |
Output is correct |
8 |
Correct |
8 ms |
14288 KB |
Output is correct |
9 |
Correct |
7 ms |
14288 KB |
Output is correct |
10 |
Correct |
8 ms |
14288 KB |
Output is correct |
11 |
Correct |
7 ms |
14288 KB |
Output is correct |
12 |
Correct |
8 ms |
14344 KB |
Output is correct |
13 |
Correct |
9 ms |
14288 KB |
Output is correct |
14 |
Correct |
9 ms |
14408 KB |
Output is correct |
15 |
Correct |
10 ms |
14288 KB |
Output is correct |
16 |
Correct |
8 ms |
14412 KB |
Output is correct |
17 |
Correct |
8 ms |
14288 KB |
Output is correct |
18 |
Correct |
8 ms |
14412 KB |
Output is correct |
19 |
Correct |
8 ms |
14288 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14324 KB |
Output is correct |
3 |
Correct |
8 ms |
14288 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
7 ms |
14392 KB |
Output is correct |
6 |
Correct |
7 ms |
14288 KB |
Output is correct |
7 |
Correct |
8 ms |
14288 KB |
Output is correct |
8 |
Correct |
8 ms |
14288 KB |
Output is correct |
9 |
Correct |
7 ms |
14288 KB |
Output is correct |
10 |
Correct |
8 ms |
14288 KB |
Output is correct |
11 |
Correct |
7 ms |
14288 KB |
Output is correct |
12 |
Correct |
8 ms |
14344 KB |
Output is correct |
13 |
Correct |
9 ms |
14288 KB |
Output is correct |
14 |
Correct |
9 ms |
14408 KB |
Output is correct |
15 |
Correct |
10 ms |
14288 KB |
Output is correct |
16 |
Correct |
8 ms |
14412 KB |
Output is correct |
17 |
Correct |
8 ms |
14288 KB |
Output is correct |
18 |
Correct |
8 ms |
14412 KB |
Output is correct |
19 |
Correct |
8 ms |
14288 KB |
Output is correct |
20 |
Correct |
8 ms |
14416 KB |
Output is correct |
21 |
Correct |
9 ms |
14416 KB |
Output is correct |
22 |
Correct |
8 ms |
14544 KB |
Output is correct |
23 |
Correct |
8 ms |
14416 KB |
Output is correct |
24 |
Correct |
9 ms |
14544 KB |
Output is correct |
25 |
Correct |
10 ms |
14544 KB |
Output is correct |
26 |
Correct |
11 ms |
14420 KB |
Output is correct |
27 |
Correct |
10 ms |
14416 KB |
Output is correct |
28 |
Correct |
8 ms |
14416 KB |
Output is correct |
29 |
Correct |
9 ms |
14416 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14324 KB |
Output is correct |
3 |
Correct |
8 ms |
14288 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
7 ms |
14392 KB |
Output is correct |
6 |
Correct |
7 ms |
14288 KB |
Output is correct |
7 |
Correct |
8 ms |
14288 KB |
Output is correct |
8 |
Correct |
8 ms |
14288 KB |
Output is correct |
9 |
Correct |
7 ms |
14288 KB |
Output is correct |
10 |
Correct |
8 ms |
14288 KB |
Output is correct |
11 |
Correct |
7 ms |
14288 KB |
Output is correct |
12 |
Correct |
8 ms |
14344 KB |
Output is correct |
13 |
Correct |
9 ms |
14288 KB |
Output is correct |
14 |
Correct |
9 ms |
14408 KB |
Output is correct |
15 |
Correct |
10 ms |
14288 KB |
Output is correct |
16 |
Correct |
8 ms |
14412 KB |
Output is correct |
17 |
Correct |
8 ms |
14288 KB |
Output is correct |
18 |
Correct |
8 ms |
14412 KB |
Output is correct |
19 |
Correct |
8 ms |
14288 KB |
Output is correct |
20 |
Correct |
8 ms |
14416 KB |
Output is correct |
21 |
Correct |
9 ms |
14416 KB |
Output is correct |
22 |
Correct |
8 ms |
14544 KB |
Output is correct |
23 |
Correct |
8 ms |
14416 KB |
Output is correct |
24 |
Correct |
9 ms |
14544 KB |
Output is correct |
25 |
Correct |
10 ms |
14544 KB |
Output is correct |
26 |
Correct |
11 ms |
14420 KB |
Output is correct |
27 |
Correct |
10 ms |
14416 KB |
Output is correct |
28 |
Correct |
8 ms |
14416 KB |
Output is correct |
29 |
Correct |
9 ms |
14416 KB |
Output is correct |
30 |
Correct |
23 ms |
15960 KB |
Output is correct |
31 |
Correct |
13 ms |
15220 KB |
Output is correct |
32 |
Correct |
27 ms |
20808 KB |
Output is correct |
33 |
Correct |
25 ms |
16696 KB |
Output is correct |
34 |
Correct |
51 ms |
24852 KB |
Output is correct |
35 |
Correct |
50 ms |
19448 KB |
Output is correct |
36 |
Correct |
43 ms |
16752 KB |
Output is correct |
37 |
Correct |
44 ms |
16756 KB |
Output is correct |
38 |
Correct |
36 ms |
16456 KB |
Output is correct |
39 |
Correct |
39 ms |
16516 KB |
Output is correct |
40 |
Correct |
33 ms |
18120 KB |
Output is correct |
41 |
Correct |
54 ms |
18340 KB |
Output is correct |
42 |
Correct |
46 ms |
18100 KB |
Output is correct |
43 |
Correct |
43 ms |
17444 KB |
Output is correct |
44 |
Correct |
57 ms |
17312 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14324 KB |
Output is correct |
3 |
Correct |
8 ms |
14288 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
7 ms |
14392 KB |
Output is correct |
6 |
Correct |
7 ms |
14288 KB |
Output is correct |
7 |
Correct |
8 ms |
14288 KB |
Output is correct |
8 |
Correct |
8 ms |
14288 KB |
Output is correct |
9 |
Correct |
7 ms |
14288 KB |
Output is correct |
10 |
Correct |
8 ms |
14288 KB |
Output is correct |
11 |
Correct |
7 ms |
14288 KB |
Output is correct |
12 |
Correct |
8 ms |
14344 KB |
Output is correct |
13 |
Correct |
9 ms |
14288 KB |
Output is correct |
14 |
Correct |
9 ms |
14408 KB |
Output is correct |
15 |
Correct |
10 ms |
14288 KB |
Output is correct |
16 |
Correct |
8 ms |
14412 KB |
Output is correct |
17 |
Correct |
8 ms |
14288 KB |
Output is correct |
18 |
Correct |
8 ms |
14412 KB |
Output is correct |
19 |
Correct |
8 ms |
14288 KB |
Output is correct |
20 |
Correct |
8 ms |
14416 KB |
Output is correct |
21 |
Correct |
9 ms |
14416 KB |
Output is correct |
22 |
Correct |
8 ms |
14544 KB |
Output is correct |
23 |
Correct |
8 ms |
14416 KB |
Output is correct |
24 |
Correct |
9 ms |
14544 KB |
Output is correct |
25 |
Correct |
10 ms |
14544 KB |
Output is correct |
26 |
Correct |
11 ms |
14420 KB |
Output is correct |
27 |
Correct |
10 ms |
14416 KB |
Output is correct |
28 |
Correct |
8 ms |
14416 KB |
Output is correct |
29 |
Correct |
9 ms |
14416 KB |
Output is correct |
30 |
Correct |
23 ms |
15960 KB |
Output is correct |
31 |
Correct |
13 ms |
15220 KB |
Output is correct |
32 |
Correct |
27 ms |
20808 KB |
Output is correct |
33 |
Correct |
25 ms |
16696 KB |
Output is correct |
34 |
Correct |
51 ms |
24852 KB |
Output is correct |
35 |
Correct |
50 ms |
19448 KB |
Output is correct |
36 |
Correct |
43 ms |
16752 KB |
Output is correct |
37 |
Correct |
44 ms |
16756 KB |
Output is correct |
38 |
Correct |
36 ms |
16456 KB |
Output is correct |
39 |
Correct |
39 ms |
16516 KB |
Output is correct |
40 |
Correct |
33 ms |
18120 KB |
Output is correct |
41 |
Correct |
54 ms |
18340 KB |
Output is correct |
42 |
Correct |
46 ms |
18100 KB |
Output is correct |
43 |
Correct |
43 ms |
17444 KB |
Output is correct |
44 |
Correct |
57 ms |
17312 KB |
Output is correct |
45 |
Correct |
254 ms |
30328 KB |
Output is correct |
46 |
Correct |
20 ms |
19428 KB |
Output is correct |
47 |
Correct |
15 ms |
19352 KB |
Output is correct |
48 |
Correct |
348 ms |
43932 KB |
Output is correct |
49 |
Correct |
283 ms |
37760 KB |
Output is correct |
50 |
Correct |
556 ms |
90016 KB |
Output is correct |
51 |
Correct |
901 ms |
69084 KB |
Output is correct |
52 |
Correct |
654 ms |
37808 KB |
Output is correct |
53 |
Correct |
863 ms |
38120 KB |
Output is correct |
54 |
Correct |
921 ms |
38092 KB |
Output is correct |
55 |
Correct |
1226 ms |
38396 KB |
Output is correct |
56 |
Correct |
1406 ms |
37720 KB |
Output is correct |
57 |
Correct |
591 ms |
31760 KB |
Output is correct |
58 |
Correct |
569 ms |
31960 KB |
Output is correct |
59 |
Correct |
600 ms |
31924 KB |
Output is correct |
60 |
Correct |
697 ms |
31764 KB |
Output is correct |
61 |
Correct |
798 ms |
31912 KB |
Output is correct |
62 |
Correct |
455 ms |
67596 KB |
Output is correct |
63 |
Correct |
323 ms |
64284 KB |
Output is correct |
64 |
Correct |
1107 ms |
109748 KB |
Output is correct |
65 |
Correct |
643 ms |
46176 KB |
Output is correct |
66 |
Correct |
431 ms |
43836 KB |
Output is correct |
67 |
Correct |
991 ms |
55404 KB |
Output is correct |
68 |
Correct |
258 ms |
28592 KB |
Output is correct |
69 |
Correct |
69 ms |
22572 KB |
Output is correct |
70 |
Correct |
981 ms |
58712 KB |
Output is correct |
71 |
Correct |
397 ms |
31508 KB |
Output is correct |
72 |
Correct |
304 ms |
27212 KB |
Output is correct |
73 |
Correct |
859 ms |
46696 KB |
Output is correct |
74 |
Correct |
1889 ms |
37828 KB |
Output is correct |
75 |
Correct |
1243 ms |
45292 KB |
Output is correct |
76 |
Correct |
1521 ms |
42684 KB |
Output is correct |