#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;
for(auto x : T[v]){
if(explore(v, x)) return 1;
}
for(auto x : R[v]){
if(explore(x, v)) return 1;
}
}
if(G[v].se < G[u].se){
G[u].se = G[v].se;
for(auto x : T[u]){
if(explore(u, x)) return 1;
}
for(auto x : R[u]){
if(explore(x, u)) 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 |
7 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14340 KB |
Output is correct |
3 |
Correct |
8 ms |
14324 KB |
Output is correct |
4 |
Correct |
8 ms |
14364 KB |
Output is correct |
5 |
Correct |
7 ms |
14288 KB |
Output is correct |
6 |
Correct |
7 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14340 KB |
Output is correct |
3 |
Correct |
8 ms |
14324 KB |
Output is correct |
4 |
Correct |
8 ms |
14364 KB |
Output is correct |
5 |
Correct |
7 ms |
14288 KB |
Output is correct |
6 |
Correct |
7 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
8 |
Correct |
8 ms |
14324 KB |
Output is correct |
9 |
Correct |
9 ms |
14288 KB |
Output is correct |
10 |
Correct |
7 ms |
14288 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 |
14416 KB |
Output is correct |
14 |
Correct |
8 ms |
14288 KB |
Output is correct |
15 |
Correct |
9 ms |
14416 KB |
Output is correct |
16 |
Correct |
7 ms |
14400 KB |
Output is correct |
17 |
Correct |
7 ms |
14288 KB |
Output is correct |
18 |
Correct |
8 ms |
14288 KB |
Output is correct |
19 |
Correct |
7 ms |
14288 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14340 KB |
Output is correct |
3 |
Correct |
8 ms |
14324 KB |
Output is correct |
4 |
Correct |
8 ms |
14364 KB |
Output is correct |
5 |
Correct |
7 ms |
14288 KB |
Output is correct |
6 |
Correct |
7 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
8 |
Correct |
8 ms |
14324 KB |
Output is correct |
9 |
Correct |
9 ms |
14288 KB |
Output is correct |
10 |
Correct |
7 ms |
14288 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 |
14416 KB |
Output is correct |
14 |
Correct |
8 ms |
14288 KB |
Output is correct |
15 |
Correct |
9 ms |
14416 KB |
Output is correct |
16 |
Correct |
7 ms |
14400 KB |
Output is correct |
17 |
Correct |
7 ms |
14288 KB |
Output is correct |
18 |
Correct |
8 ms |
14288 KB |
Output is correct |
19 |
Correct |
7 ms |
14288 KB |
Output is correct |
20 |
Correct |
8 ms |
14416 KB |
Output is correct |
21 |
Correct |
8 ms |
14424 KB |
Output is correct |
22 |
Correct |
9 ms |
14416 KB |
Output is correct |
23 |
Correct |
9 ms |
14424 KB |
Output is correct |
24 |
Correct |
17 ms |
14416 KB |
Output is correct |
25 |
Correct |
12 ms |
14416 KB |
Output is correct |
26 |
Correct |
10 ms |
14416 KB |
Output is correct |
27 |
Correct |
9 ms |
14416 KB |
Output is correct |
28 |
Correct |
8 ms |
14416 KB |
Output is correct |
29 |
Correct |
11 ms |
14480 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14340 KB |
Output is correct |
3 |
Correct |
8 ms |
14324 KB |
Output is correct |
4 |
Correct |
8 ms |
14364 KB |
Output is correct |
5 |
Correct |
7 ms |
14288 KB |
Output is correct |
6 |
Correct |
7 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
8 |
Correct |
8 ms |
14324 KB |
Output is correct |
9 |
Correct |
9 ms |
14288 KB |
Output is correct |
10 |
Correct |
7 ms |
14288 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 |
14416 KB |
Output is correct |
14 |
Correct |
8 ms |
14288 KB |
Output is correct |
15 |
Correct |
9 ms |
14416 KB |
Output is correct |
16 |
Correct |
7 ms |
14400 KB |
Output is correct |
17 |
Correct |
7 ms |
14288 KB |
Output is correct |
18 |
Correct |
8 ms |
14288 KB |
Output is correct |
19 |
Correct |
7 ms |
14288 KB |
Output is correct |
20 |
Correct |
8 ms |
14416 KB |
Output is correct |
21 |
Correct |
8 ms |
14424 KB |
Output is correct |
22 |
Correct |
9 ms |
14416 KB |
Output is correct |
23 |
Correct |
9 ms |
14424 KB |
Output is correct |
24 |
Correct |
17 ms |
14416 KB |
Output is correct |
25 |
Correct |
12 ms |
14416 KB |
Output is correct |
26 |
Correct |
10 ms |
14416 KB |
Output is correct |
27 |
Correct |
9 ms |
14416 KB |
Output is correct |
28 |
Correct |
8 ms |
14416 KB |
Output is correct |
29 |
Correct |
11 ms |
14480 KB |
Output is correct |
30 |
Correct |
24 ms |
16024 KB |
Output is correct |
31 |
Correct |
13 ms |
15276 KB |
Output is correct |
32 |
Correct |
29 ms |
17120 KB |
Output is correct |
33 |
Correct |
31 ms |
16712 KB |
Output is correct |
34 |
Correct |
1780 ms |
19100 KB |
Output is correct |
35 |
Correct |
450 ms |
17452 KB |
Output is correct |
36 |
Correct |
48 ms |
16668 KB |
Output is correct |
37 |
Correct |
41 ms |
16748 KB |
Output is correct |
38 |
Correct |
44 ms |
16428 KB |
Output is correct |
39 |
Correct |
50 ms |
16432 KB |
Output is correct |
40 |
Correct |
1376 ms |
19068 KB |
Output is correct |
41 |
Correct |
192 ms |
17096 KB |
Output is correct |
42 |
Correct |
145 ms |
16840 KB |
Output is correct |
43 |
Correct |
49 ms |
17992 KB |
Output is correct |
44 |
Correct |
1202 ms |
19088 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14340 KB |
Output is correct |
3 |
Correct |
8 ms |
14324 KB |
Output is correct |
4 |
Correct |
8 ms |
14364 KB |
Output is correct |
5 |
Correct |
7 ms |
14288 KB |
Output is correct |
6 |
Correct |
7 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
8 |
Correct |
8 ms |
14324 KB |
Output is correct |
9 |
Correct |
9 ms |
14288 KB |
Output is correct |
10 |
Correct |
7 ms |
14288 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 |
14416 KB |
Output is correct |
14 |
Correct |
8 ms |
14288 KB |
Output is correct |
15 |
Correct |
9 ms |
14416 KB |
Output is correct |
16 |
Correct |
7 ms |
14400 KB |
Output is correct |
17 |
Correct |
7 ms |
14288 KB |
Output is correct |
18 |
Correct |
8 ms |
14288 KB |
Output is correct |
19 |
Correct |
7 ms |
14288 KB |
Output is correct |
20 |
Correct |
8 ms |
14416 KB |
Output is correct |
21 |
Correct |
8 ms |
14424 KB |
Output is correct |
22 |
Correct |
9 ms |
14416 KB |
Output is correct |
23 |
Correct |
9 ms |
14424 KB |
Output is correct |
24 |
Correct |
17 ms |
14416 KB |
Output is correct |
25 |
Correct |
12 ms |
14416 KB |
Output is correct |
26 |
Correct |
10 ms |
14416 KB |
Output is correct |
27 |
Correct |
9 ms |
14416 KB |
Output is correct |
28 |
Correct |
8 ms |
14416 KB |
Output is correct |
29 |
Correct |
11 ms |
14480 KB |
Output is correct |
30 |
Correct |
24 ms |
16024 KB |
Output is correct |
31 |
Correct |
13 ms |
15276 KB |
Output is correct |
32 |
Correct |
29 ms |
17120 KB |
Output is correct |
33 |
Correct |
31 ms |
16712 KB |
Output is correct |
34 |
Correct |
1780 ms |
19100 KB |
Output is correct |
35 |
Correct |
450 ms |
17452 KB |
Output is correct |
36 |
Correct |
48 ms |
16668 KB |
Output is correct |
37 |
Correct |
41 ms |
16748 KB |
Output is correct |
38 |
Correct |
44 ms |
16428 KB |
Output is correct |
39 |
Correct |
50 ms |
16432 KB |
Output is correct |
40 |
Correct |
1376 ms |
19068 KB |
Output is correct |
41 |
Correct |
192 ms |
17096 KB |
Output is correct |
42 |
Correct |
145 ms |
16840 KB |
Output is correct |
43 |
Correct |
49 ms |
17992 KB |
Output is correct |
44 |
Correct |
1202 ms |
19088 KB |
Output is correct |
45 |
Correct |
263 ms |
30484 KB |
Output is correct |
46 |
Correct |
17 ms |
19536 KB |
Output is correct |
47 |
Correct |
17 ms |
19436 KB |
Output is correct |
48 |
Correct |
355 ms |
47896 KB |
Output is correct |
49 |
Correct |
295 ms |
37900 KB |
Output is correct |
50 |
Execution timed out |
4045 ms |
40204 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |