#include "game.h"
#include <bits/stdc++.h>
using namespace std;
// trans rights
#define ll long long
#define f first
#define s second
#define endl '\n'
#define all(x) begin(x), end(x)
#define bkt 547
int n,k;
bool flag;
vector<int> grph[300069],revs[300069];
int lft[300069],rht[300069];
void init(int N, int K) {
n=N;
k=K;
for (int i = 0; i < k; i++) {
lft[i]=i/bkt;
rht[i]=i;
}
for (int i = k; i < n; i++) {
lft[i]=-1;
rht[i]=k;
}
}
void dfs(int x) {
for (int i : grph[x]) {
if (i<k&&i/bkt<lft[x]) {
flag=true;
}
if (lft[i]<lft[x]) {
lft[i]=lft[x];
dfs(i);
}
if (x<k&&x>=rht[i]) {
flag=true;
}
if (rht[x]>rht[i]&&rht[i]/bkt==lft[x]) {
rht[x]=rht[i];
}
}
}
void rdfs(int x) {
for (int i : revs[x]) {
if (i<k&&i>=rht[x]) {
flag=true;
}
if (rht[i]>rht[x]&&rht[x]/bkt==lft[i]) {
rht[i]=rht[x];
rdfs(i);
}
}
}
int add_teleporter(int u, int v) {
grph[u].push_back(v);
revs[v].push_back(u);
dfs(u);
rdfs(u);
/*for (int i = 0; i < n; i++) {
cout<<lft[i]<<' '<<rht[i]<<endl;
}
cout<<endl;*/
return flag;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14296 KB |
Output is correct |
3 |
Correct |
8 ms |
14288 KB |
Output is correct |
4 |
Correct |
9 ms |
14288 KB |
Output is correct |
5 |
Correct |
8 ms |
14288 KB |
Output is correct |
6 |
Correct |
8 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14296 KB |
Output is correct |
3 |
Correct |
8 ms |
14288 KB |
Output is correct |
4 |
Correct |
9 ms |
14288 KB |
Output is correct |
5 |
Correct |
8 ms |
14288 KB |
Output is correct |
6 |
Correct |
8 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
8 |
Correct |
7 ms |
14356 KB |
Output is correct |
9 |
Correct |
7 ms |
14288 KB |
Output is correct |
10 |
Correct |
7 ms |
14288 KB |
Output is correct |
11 |
Correct |
7 ms |
14288 KB |
Output is correct |
12 |
Correct |
8 ms |
14288 KB |
Output is correct |
13 |
Correct |
7 ms |
14288 KB |
Output is correct |
14 |
Correct |
8 ms |
14460 KB |
Output is correct |
15 |
Correct |
7 ms |
14288 KB |
Output is correct |
16 |
Correct |
8 ms |
14412 KB |
Output is correct |
17 |
Correct |
9 ms |
14336 KB |
Output is correct |
18 |
Correct |
8 ms |
14288 KB |
Output is correct |
19 |
Correct |
9 ms |
14288 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14296 KB |
Output is correct |
3 |
Correct |
8 ms |
14288 KB |
Output is correct |
4 |
Correct |
9 ms |
14288 KB |
Output is correct |
5 |
Correct |
8 ms |
14288 KB |
Output is correct |
6 |
Correct |
8 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
8 |
Correct |
7 ms |
14356 KB |
Output is correct |
9 |
Correct |
7 ms |
14288 KB |
Output is correct |
10 |
Correct |
7 ms |
14288 KB |
Output is correct |
11 |
Correct |
7 ms |
14288 KB |
Output is correct |
12 |
Correct |
8 ms |
14288 KB |
Output is correct |
13 |
Correct |
7 ms |
14288 KB |
Output is correct |
14 |
Correct |
8 ms |
14460 KB |
Output is correct |
15 |
Correct |
7 ms |
14288 KB |
Output is correct |
16 |
Correct |
8 ms |
14412 KB |
Output is correct |
17 |
Correct |
9 ms |
14336 KB |
Output is correct |
18 |
Correct |
8 ms |
14288 KB |
Output is correct |
19 |
Correct |
9 ms |
14288 KB |
Output is correct |
20 |
Correct |
11 ms |
14416 KB |
Output is correct |
21 |
Correct |
10 ms |
14416 KB |
Output is correct |
22 |
Correct |
9 ms |
14416 KB |
Output is correct |
23 |
Correct |
9 ms |
14416 KB |
Output is correct |
24 |
Correct |
11 ms |
14448 KB |
Output is correct |
25 |
Correct |
15 ms |
14484 KB |
Output is correct |
26 |
Correct |
9 ms |
14420 KB |
Output is correct |
27 |
Correct |
10 ms |
14424 KB |
Output is correct |
28 |
Correct |
9 ms |
14432 KB |
Output is correct |
29 |
Correct |
11 ms |
14416 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14296 KB |
Output is correct |
3 |
Correct |
8 ms |
14288 KB |
Output is correct |
4 |
Correct |
9 ms |
14288 KB |
Output is correct |
5 |
Correct |
8 ms |
14288 KB |
Output is correct |
6 |
Correct |
8 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
8 |
Correct |
7 ms |
14356 KB |
Output is correct |
9 |
Correct |
7 ms |
14288 KB |
Output is correct |
10 |
Correct |
7 ms |
14288 KB |
Output is correct |
11 |
Correct |
7 ms |
14288 KB |
Output is correct |
12 |
Correct |
8 ms |
14288 KB |
Output is correct |
13 |
Correct |
7 ms |
14288 KB |
Output is correct |
14 |
Correct |
8 ms |
14460 KB |
Output is correct |
15 |
Correct |
7 ms |
14288 KB |
Output is correct |
16 |
Correct |
8 ms |
14412 KB |
Output is correct |
17 |
Correct |
9 ms |
14336 KB |
Output is correct |
18 |
Correct |
8 ms |
14288 KB |
Output is correct |
19 |
Correct |
9 ms |
14288 KB |
Output is correct |
20 |
Correct |
11 ms |
14416 KB |
Output is correct |
21 |
Correct |
10 ms |
14416 KB |
Output is correct |
22 |
Correct |
9 ms |
14416 KB |
Output is correct |
23 |
Correct |
9 ms |
14416 KB |
Output is correct |
24 |
Correct |
11 ms |
14448 KB |
Output is correct |
25 |
Correct |
15 ms |
14484 KB |
Output is correct |
26 |
Correct |
9 ms |
14420 KB |
Output is correct |
27 |
Correct |
10 ms |
14424 KB |
Output is correct |
28 |
Correct |
9 ms |
14432 KB |
Output is correct |
29 |
Correct |
11 ms |
14416 KB |
Output is correct |
30 |
Correct |
46 ms |
15736 KB |
Output is correct |
31 |
Correct |
18 ms |
15008 KB |
Output is correct |
32 |
Correct |
42 ms |
17068 KB |
Output is correct |
33 |
Correct |
36 ms |
16484 KB |
Output is correct |
34 |
Correct |
73 ms |
18632 KB |
Output is correct |
35 |
Correct |
61 ms |
17308 KB |
Output is correct |
36 |
Correct |
78 ms |
16464 KB |
Output is correct |
37 |
Correct |
48 ms |
16348 KB |
Output is correct |
38 |
Correct |
43 ms |
16192 KB |
Output is correct |
39 |
Correct |
66 ms |
16252 KB |
Output is correct |
40 |
Correct |
144 ms |
18716 KB |
Output is correct |
41 |
Correct |
86 ms |
16844 KB |
Output is correct |
42 |
Correct |
65 ms |
16604 KB |
Output is correct |
43 |
Correct |
51 ms |
17848 KB |
Output is correct |
44 |
Correct |
161 ms |
18320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14296 KB |
Output is correct |
3 |
Correct |
8 ms |
14288 KB |
Output is correct |
4 |
Correct |
9 ms |
14288 KB |
Output is correct |
5 |
Correct |
8 ms |
14288 KB |
Output is correct |
6 |
Correct |
8 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
8 |
Correct |
7 ms |
14356 KB |
Output is correct |
9 |
Correct |
7 ms |
14288 KB |
Output is correct |
10 |
Correct |
7 ms |
14288 KB |
Output is correct |
11 |
Correct |
7 ms |
14288 KB |
Output is correct |
12 |
Correct |
8 ms |
14288 KB |
Output is correct |
13 |
Correct |
7 ms |
14288 KB |
Output is correct |
14 |
Correct |
8 ms |
14460 KB |
Output is correct |
15 |
Correct |
7 ms |
14288 KB |
Output is correct |
16 |
Correct |
8 ms |
14412 KB |
Output is correct |
17 |
Correct |
9 ms |
14336 KB |
Output is correct |
18 |
Correct |
8 ms |
14288 KB |
Output is correct |
19 |
Correct |
9 ms |
14288 KB |
Output is correct |
20 |
Correct |
11 ms |
14416 KB |
Output is correct |
21 |
Correct |
10 ms |
14416 KB |
Output is correct |
22 |
Correct |
9 ms |
14416 KB |
Output is correct |
23 |
Correct |
9 ms |
14416 KB |
Output is correct |
24 |
Correct |
11 ms |
14448 KB |
Output is correct |
25 |
Correct |
15 ms |
14484 KB |
Output is correct |
26 |
Correct |
9 ms |
14420 KB |
Output is correct |
27 |
Correct |
10 ms |
14424 KB |
Output is correct |
28 |
Correct |
9 ms |
14432 KB |
Output is correct |
29 |
Correct |
11 ms |
14416 KB |
Output is correct |
30 |
Correct |
46 ms |
15736 KB |
Output is correct |
31 |
Correct |
18 ms |
15008 KB |
Output is correct |
32 |
Correct |
42 ms |
17068 KB |
Output is correct |
33 |
Correct |
36 ms |
16484 KB |
Output is correct |
34 |
Correct |
73 ms |
18632 KB |
Output is correct |
35 |
Correct |
61 ms |
17308 KB |
Output is correct |
36 |
Correct |
78 ms |
16464 KB |
Output is correct |
37 |
Correct |
48 ms |
16348 KB |
Output is correct |
38 |
Correct |
43 ms |
16192 KB |
Output is correct |
39 |
Correct |
66 ms |
16252 KB |
Output is correct |
40 |
Correct |
144 ms |
18716 KB |
Output is correct |
41 |
Correct |
86 ms |
16844 KB |
Output is correct |
42 |
Correct |
65 ms |
16604 KB |
Output is correct |
43 |
Correct |
51 ms |
17848 KB |
Output is correct |
44 |
Correct |
161 ms |
18320 KB |
Output is correct |
45 |
Correct |
347 ms |
28084 KB |
Output is correct |
46 |
Correct |
20 ms |
17124 KB |
Output is correct |
47 |
Correct |
17 ms |
17104 KB |
Output is correct |
48 |
Correct |
450 ms |
45568 KB |
Output is correct |
49 |
Correct |
410 ms |
35444 KB |
Output is correct |
50 |
Execution timed out |
4032 ms |
40488 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |