#include "game.h"
#include <bits/stdc++.h>
#include <bits/extc++.h>
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define ef(a) emplace_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define tomax(a, b) ((a) = max((a), (b)))
#define tomin(a, b) ((a) = min((a), (b)))
#define topos(a) ((a) = (((a) % MOD + MOD) % MOD))
#define uni(a) a.resize(unique(iter(a)) - a.begin())
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
if(pvaspace) b << " "; pvaspace=true;\
b << pva;\
}\
b << "\n";}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;
const ll MOD = 1000000007;
const ll MAX = 2147483647;
template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
return o << '(' << p.F << ',' << p.S << ')';
}
ll ifloor(ll a, ll b){
if(b < 0) a *= -1, b *= -1;
if(a < 0) return (a - b + 1) / b;
else return a / b;
}
ll iceil(ll a, ll b){
if(b < 0) a *= -1, b *= -1;
if(a > 0) return (a + b - 1) / b;
else return a / b;
}
int n, k;
vector<int> lk, rk;
vector<vector<int>> g, rg;
int ans = 0;
void add(int u, int v){
if(lk[u] >= rk[v]) return ans = 1, void();
while((lk[u] + rk[u]) / 2 >= rk[v]){
rk[u] = (lk[u] + rk[u]) / 2;
for(int i : rg[u]){
add(i, u);
if(ans == 1) return;
}
}
while((lk[v] + rk[v]) / 2 + 1 <= lk[u]){
lk[v] = (lk[v] + rk[v]) / 2 + 1;
for(int i : g[v]){
add(v, i);
if(ans == 1) return;
}
}
}
void init(int _n, int _k){
n = _n;
k = _k;
lk.resize(n + 1, 0);
rk.resize(n + 1, k + 1);
g.resize(n + 1);
rg.resize(n + 1);
for(int i = 1; i <= k; i++){
lk[i] = rk[i] = i;
if(i + 1 <= k){
g[i].eb(i + 1);
rg[i + 1].eb(i);
}
}
}
int add_teleporter(int u, int v){
u++;
v++;
g[u].eb(v);
rg[v].eb(u);
add(u, v);
/*cerr << "add " << u << " " << v << "\n";
printv(lk, cerr);
printv(rk, cerr);*/
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
0 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
0 ms |
312 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
208 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
0 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
0 ms |
312 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
208 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
1 ms |
208 KB |
Output is correct |
20 |
Correct |
1 ms |
368 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
464 KB |
Output is correct |
25 |
Correct |
2 ms |
464 KB |
Output is correct |
26 |
Correct |
4 ms |
336 KB |
Output is correct |
27 |
Correct |
2 ms |
336 KB |
Output is correct |
28 |
Correct |
2 ms |
464 KB |
Output is correct |
29 |
Correct |
2 ms |
464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
0 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
0 ms |
312 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
208 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
1 ms |
208 KB |
Output is correct |
20 |
Correct |
1 ms |
368 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
464 KB |
Output is correct |
25 |
Correct |
2 ms |
464 KB |
Output is correct |
26 |
Correct |
4 ms |
336 KB |
Output is correct |
27 |
Correct |
2 ms |
336 KB |
Output is correct |
28 |
Correct |
2 ms |
464 KB |
Output is correct |
29 |
Correct |
2 ms |
464 KB |
Output is correct |
30 |
Correct |
20 ms |
3064 KB |
Output is correct |
31 |
Correct |
8 ms |
2344 KB |
Output is correct |
32 |
Correct |
31 ms |
6020 KB |
Output is correct |
33 |
Correct |
19 ms |
3796 KB |
Output is correct |
34 |
Correct |
33 ms |
8348 KB |
Output is correct |
35 |
Correct |
36 ms |
5292 KB |
Output is correct |
36 |
Correct |
45 ms |
3808 KB |
Output is correct |
37 |
Correct |
45 ms |
3908 KB |
Output is correct |
38 |
Correct |
33 ms |
3672 KB |
Output is correct |
39 |
Correct |
37 ms |
3540 KB |
Output is correct |
40 |
Correct |
43 ms |
8092 KB |
Output is correct |
41 |
Correct |
36 ms |
4836 KB |
Output is correct |
42 |
Correct |
31 ms |
4296 KB |
Output is correct |
43 |
Correct |
58 ms |
5072 KB |
Output is correct |
44 |
Correct |
53 ms |
4940 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
0 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
0 ms |
312 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
208 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
1 ms |
208 KB |
Output is correct |
20 |
Correct |
1 ms |
368 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
464 KB |
Output is correct |
25 |
Correct |
2 ms |
464 KB |
Output is correct |
26 |
Correct |
4 ms |
336 KB |
Output is correct |
27 |
Correct |
2 ms |
336 KB |
Output is correct |
28 |
Correct |
2 ms |
464 KB |
Output is correct |
29 |
Correct |
2 ms |
464 KB |
Output is correct |
30 |
Correct |
20 ms |
3064 KB |
Output is correct |
31 |
Correct |
8 ms |
2344 KB |
Output is correct |
32 |
Correct |
31 ms |
6020 KB |
Output is correct |
33 |
Correct |
19 ms |
3796 KB |
Output is correct |
34 |
Correct |
33 ms |
8348 KB |
Output is correct |
35 |
Correct |
36 ms |
5292 KB |
Output is correct |
36 |
Correct |
45 ms |
3808 KB |
Output is correct |
37 |
Correct |
45 ms |
3908 KB |
Output is correct |
38 |
Correct |
33 ms |
3672 KB |
Output is correct |
39 |
Correct |
37 ms |
3540 KB |
Output is correct |
40 |
Correct |
43 ms |
8092 KB |
Output is correct |
41 |
Correct |
36 ms |
4836 KB |
Output is correct |
42 |
Correct |
31 ms |
4296 KB |
Output is correct |
43 |
Correct |
58 ms |
5072 KB |
Output is correct |
44 |
Correct |
53 ms |
4940 KB |
Output is correct |
45 |
Correct |
275 ms |
28084 KB |
Output is correct |
46 |
Correct |
16 ms |
17152 KB |
Output is correct |
47 |
Correct |
15 ms |
17232 KB |
Output is correct |
48 |
Correct |
391 ms |
45592 KB |
Output is correct |
49 |
Correct |
303 ms |
35468 KB |
Output is correct |
50 |
Correct |
711 ms |
59720 KB |
Output is correct |
51 |
Correct |
946 ms |
48036 KB |
Output is correct |
52 |
Correct |
624 ms |
35576 KB |
Output is correct |
53 |
Correct |
846 ms |
35748 KB |
Output is correct |
54 |
Correct |
904 ms |
35852 KB |
Output is correct |
55 |
Correct |
995 ms |
35804 KB |
Output is correct |
56 |
Correct |
1151 ms |
36040 KB |
Output is correct |
57 |
Correct |
602 ms |
35740 KB |
Output is correct |
58 |
Correct |
619 ms |
36140 KB |
Output is correct |
59 |
Correct |
559 ms |
35896 KB |
Output is correct |
60 |
Correct |
562 ms |
36104 KB |
Output is correct |
61 |
Correct |
645 ms |
36204 KB |
Output is correct |
62 |
Correct |
485 ms |
44276 KB |
Output is correct |
63 |
Correct |
390 ms |
41144 KB |
Output is correct |
64 |
Correct |
1174 ms |
71412 KB |
Output is correct |
65 |
Correct |
552 ms |
37900 KB |
Output is correct |
66 |
Correct |
421 ms |
34068 KB |
Output is correct |
67 |
Correct |
954 ms |
43632 KB |
Output is correct |
68 |
Correct |
234 ms |
29552 KB |
Output is correct |
69 |
Correct |
64 ms |
23512 KB |
Output is correct |
70 |
Correct |
840 ms |
46444 KB |
Output is correct |
71 |
Correct |
379 ms |
30280 KB |
Output is correct |
72 |
Correct |
231 ms |
26336 KB |
Output is correct |
73 |
Correct |
743 ms |
40968 KB |
Output is correct |
74 |
Correct |
1283 ms |
36340 KB |
Output is correct |
75 |
Correct |
1141 ms |
47924 KB |
Output is correct |
76 |
Correct |
1139 ms |
55256 KB |
Output is correct |