#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
const int N = 3e5 + 5;
const int oo = 1e18 + 7, mod = 1e9 + 7;
int n, k;
vector<int> Adj[N], Adj2[N];
int mn[N], mx[N];
void init(int n_, int k_){
n = n_, k = k_;
for(int i = 0; i < n; i++){
mn[i] = oo, mx[i] = -oo;
}
for(int i = 0; i <= (k - 2); i++){
Adj[i].pb(i + 1);
Adj2[i + 1].pb(i);
}
for(int i = 0; i < k; i++){
if(i >= 1) mx[i] = i - 1;
if(i != (k - 1)) mn[i] = i + 1;
}
}
//int mx[N], mn[N];// have path from mx[] -> x, x -> mn[]
bool ck = 0;
//vector<int> Adj2[N];
void upd1(int u){
ck |= (mx[u] >= mn[u]);
for(auto v : Adj[u]){
if(mx[v] < mx[u]){
mx[v] = mx[u];
upd1(v);
}
}
}
void upd2(int u){
ck |= (mx[u] >= mn[u]);
for(auto v : Adj2[u]){
if(mn[v] > mn[u]){
mn[v] = mn[u];
upd2(v);
}
}
}
int add_teleporter(int x, int y){
Adj[x].pb(y);
Adj2[y].pb(x);
if(x < k && y < k){
if(x >= y) ck = 1;
}
else if(x < k){
mx[y] = max(mx[y], x);
}
else if(y < k){
mn[x] = min(mn[x], y);
}
upd1(x);
upd1(y);
upd2(x);
upd2(y);
// for(int i = 0; i < n; i++) cout << mn[i] << " " << mx[i] << "\n";
return ck;
}
Compilation message
game.cpp:16:21: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
16 | const int oo = 1e18 + 7, mod = 1e9 + 7;
| ~~~~~^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14300 KB |
Output is correct |
3 |
Correct |
8 ms |
14416 KB |
Output is correct |
4 |
Correct |
10 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 |
8 ms |
14288 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14300 KB |
Output is correct |
3 |
Correct |
8 ms |
14416 KB |
Output is correct |
4 |
Correct |
10 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 |
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 |
14352 KB |
Output is correct |
12 |
Correct |
7 ms |
14288 KB |
Output is correct |
13 |
Correct |
7 ms |
14332 KB |
Output is correct |
14 |
Correct |
8 ms |
14288 KB |
Output is correct |
15 |
Correct |
8 ms |
14288 KB |
Output is correct |
16 |
Correct |
7 ms |
14408 KB |
Output is correct |
17 |
Correct |
7 ms |
14304 KB |
Output is correct |
18 |
Correct |
7 ms |
14384 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 |
14300 KB |
Output is correct |
3 |
Correct |
8 ms |
14416 KB |
Output is correct |
4 |
Correct |
10 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 |
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 |
14352 KB |
Output is correct |
12 |
Correct |
7 ms |
14288 KB |
Output is correct |
13 |
Correct |
7 ms |
14332 KB |
Output is correct |
14 |
Correct |
8 ms |
14288 KB |
Output is correct |
15 |
Correct |
8 ms |
14288 KB |
Output is correct |
16 |
Correct |
7 ms |
14408 KB |
Output is correct |
17 |
Correct |
7 ms |
14304 KB |
Output is correct |
18 |
Correct |
7 ms |
14384 KB |
Output is correct |
19 |
Correct |
8 ms |
14288 KB |
Output is correct |
20 |
Correct |
9 ms |
14436 KB |
Output is correct |
21 |
Correct |
8 ms |
14288 KB |
Output is correct |
22 |
Correct |
8 ms |
14460 KB |
Output is correct |
23 |
Correct |
8 ms |
14416 KB |
Output is correct |
24 |
Correct |
11 ms |
14416 KB |
Output is correct |
25 |
Correct |
11 ms |
14416 KB |
Output is correct |
26 |
Correct |
11 ms |
14416 KB |
Output is correct |
27 |
Correct |
10 ms |
14416 KB |
Output is correct |
28 |
Correct |
9 ms |
14448 KB |
Output is correct |
29 |
Correct |
10 ms |
14440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14300 KB |
Output is correct |
3 |
Correct |
8 ms |
14416 KB |
Output is correct |
4 |
Correct |
10 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 |
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 |
14352 KB |
Output is correct |
12 |
Correct |
7 ms |
14288 KB |
Output is correct |
13 |
Correct |
7 ms |
14332 KB |
Output is correct |
14 |
Correct |
8 ms |
14288 KB |
Output is correct |
15 |
Correct |
8 ms |
14288 KB |
Output is correct |
16 |
Correct |
7 ms |
14408 KB |
Output is correct |
17 |
Correct |
7 ms |
14304 KB |
Output is correct |
18 |
Correct |
7 ms |
14384 KB |
Output is correct |
19 |
Correct |
8 ms |
14288 KB |
Output is correct |
20 |
Correct |
9 ms |
14436 KB |
Output is correct |
21 |
Correct |
8 ms |
14288 KB |
Output is correct |
22 |
Correct |
8 ms |
14460 KB |
Output is correct |
23 |
Correct |
8 ms |
14416 KB |
Output is correct |
24 |
Correct |
11 ms |
14416 KB |
Output is correct |
25 |
Correct |
11 ms |
14416 KB |
Output is correct |
26 |
Correct |
11 ms |
14416 KB |
Output is correct |
27 |
Correct |
10 ms |
14416 KB |
Output is correct |
28 |
Correct |
9 ms |
14448 KB |
Output is correct |
29 |
Correct |
10 ms |
14440 KB |
Output is correct |
30 |
Correct |
25 ms |
15664 KB |
Output is correct |
31 |
Correct |
14 ms |
15056 KB |
Output is correct |
32 |
Correct |
27 ms |
17068 KB |
Output is correct |
33 |
Correct |
28 ms |
16424 KB |
Output is correct |
34 |
Correct |
1136 ms |
17856 KB |
Output is correct |
35 |
Correct |
391 ms |
17132 KB |
Output is correct |
36 |
Correct |
50 ms |
16380 KB |
Output is correct |
37 |
Correct |
39 ms |
16436 KB |
Output is correct |
38 |
Correct |
34 ms |
16208 KB |
Output is correct |
39 |
Correct |
40 ms |
16304 KB |
Output is correct |
40 |
Correct |
938 ms |
17916 KB |
Output is correct |
41 |
Correct |
173 ms |
16668 KB |
Output is correct |
42 |
Correct |
113 ms |
16484 KB |
Output is correct |
43 |
Correct |
56 ms |
17992 KB |
Output is correct |
44 |
Correct |
777 ms |
17892 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14300 KB |
Output is correct |
3 |
Correct |
8 ms |
14416 KB |
Output is correct |
4 |
Correct |
10 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 |
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 |
14352 KB |
Output is correct |
12 |
Correct |
7 ms |
14288 KB |
Output is correct |
13 |
Correct |
7 ms |
14332 KB |
Output is correct |
14 |
Correct |
8 ms |
14288 KB |
Output is correct |
15 |
Correct |
8 ms |
14288 KB |
Output is correct |
16 |
Correct |
7 ms |
14408 KB |
Output is correct |
17 |
Correct |
7 ms |
14304 KB |
Output is correct |
18 |
Correct |
7 ms |
14384 KB |
Output is correct |
19 |
Correct |
8 ms |
14288 KB |
Output is correct |
20 |
Correct |
9 ms |
14436 KB |
Output is correct |
21 |
Correct |
8 ms |
14288 KB |
Output is correct |
22 |
Correct |
8 ms |
14460 KB |
Output is correct |
23 |
Correct |
8 ms |
14416 KB |
Output is correct |
24 |
Correct |
11 ms |
14416 KB |
Output is correct |
25 |
Correct |
11 ms |
14416 KB |
Output is correct |
26 |
Correct |
11 ms |
14416 KB |
Output is correct |
27 |
Correct |
10 ms |
14416 KB |
Output is correct |
28 |
Correct |
9 ms |
14448 KB |
Output is correct |
29 |
Correct |
10 ms |
14440 KB |
Output is correct |
30 |
Correct |
25 ms |
15664 KB |
Output is correct |
31 |
Correct |
14 ms |
15056 KB |
Output is correct |
32 |
Correct |
27 ms |
17068 KB |
Output is correct |
33 |
Correct |
28 ms |
16424 KB |
Output is correct |
34 |
Correct |
1136 ms |
17856 KB |
Output is correct |
35 |
Correct |
391 ms |
17132 KB |
Output is correct |
36 |
Correct |
50 ms |
16380 KB |
Output is correct |
37 |
Correct |
39 ms |
16436 KB |
Output is correct |
38 |
Correct |
34 ms |
16208 KB |
Output is correct |
39 |
Correct |
40 ms |
16304 KB |
Output is correct |
40 |
Correct |
938 ms |
17916 KB |
Output is correct |
41 |
Correct |
173 ms |
16668 KB |
Output is correct |
42 |
Correct |
113 ms |
16484 KB |
Output is correct |
43 |
Correct |
56 ms |
17992 KB |
Output is correct |
44 |
Correct |
777 ms |
17892 KB |
Output is correct |
45 |
Correct |
306 ms |
28004 KB |
Output is correct |
46 |
Correct |
17 ms |
17224 KB |
Output is correct |
47 |
Correct |
14 ms |
17196 KB |
Output is correct |
48 |
Correct |
417 ms |
42600 KB |
Output is correct |
49 |
Correct |
314 ms |
35420 KB |
Output is correct |
50 |
Execution timed out |
4078 ms |
42664 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |