# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
974873 |
2024-05-04T04:12:31 Z |
Tuanlinh123 |
Game (APIO22_game) |
C++17 |
|
1237 ms |
64188 KB |
#include "game.h"
#include<bits/stdc++.h>
#define ll int
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
#define sz(a) ((ll)(a).size())
using namespace std;
const ll maxn=300005;
ll n, k, ok, l[maxn], r[maxn], layer[maxn];
vector <ll> A[maxn], At[maxn];
void propagate(ll u)
{
if (ok) return;
if (r[u]<=l[u]) return ok=1, void();
ll j=__lg(l[u]^r[u]);
if (layer[u]>j) layer[u]=j;
else return;
for (ll v:A[u]) l[v]=max(l[v], l[u]), propagate(v);
for (ll v:At[u]) r[v]=min(r[v], r[u]), propagate(v);
}
ll addedge(ll u, ll v)
{
A[u].pb(v), At[v].pb(u);
l[v]=max(l[v], max(l[u], u<k?u:-1)), propagate(v);
r[u]=min(r[u], min(r[v], v<k?v:k)), propagate(u);
return ok;
}
void init(int N, int K)
{
n=N, k=K;
for (ll i=0; i<k; i++) l[i]=i, r[i]=i+1;
for (ll i=k; i<n; i++) l[i]=-1, r[i]=k;
for (ll i=0; i<n; i++) layer[i]=__lg(l[i]^r[i]);
}
int add_teleporter(int u, int v) {return addedge(u, v);}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
16984 KB |
Output is correct |
2 |
Correct |
4 ms |
16984 KB |
Output is correct |
3 |
Correct |
3 ms |
16984 KB |
Output is correct |
4 |
Correct |
4 ms |
16984 KB |
Output is correct |
5 |
Correct |
4 ms |
17236 KB |
Output is correct |
6 |
Correct |
4 ms |
16984 KB |
Output is correct |
7 |
Correct |
4 ms |
17240 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
16984 KB |
Output is correct |
2 |
Correct |
4 ms |
16984 KB |
Output is correct |
3 |
Correct |
3 ms |
16984 KB |
Output is correct |
4 |
Correct |
4 ms |
16984 KB |
Output is correct |
5 |
Correct |
4 ms |
17236 KB |
Output is correct |
6 |
Correct |
4 ms |
16984 KB |
Output is correct |
7 |
Correct |
4 ms |
17240 KB |
Output is correct |
8 |
Correct |
3 ms |
16984 KB |
Output is correct |
9 |
Correct |
3 ms |
16984 KB |
Output is correct |
10 |
Correct |
3 ms |
16984 KB |
Output is correct |
11 |
Correct |
4 ms |
16984 KB |
Output is correct |
12 |
Correct |
4 ms |
16984 KB |
Output is correct |
13 |
Correct |
4 ms |
16984 KB |
Output is correct |
14 |
Correct |
4 ms |
16984 KB |
Output is correct |
15 |
Correct |
3 ms |
16984 KB |
Output is correct |
16 |
Correct |
5 ms |
17240 KB |
Output is correct |
17 |
Correct |
4 ms |
17236 KB |
Output is correct |
18 |
Correct |
3 ms |
16984 KB |
Output is correct |
19 |
Correct |
3 ms |
17012 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
16984 KB |
Output is correct |
2 |
Correct |
4 ms |
16984 KB |
Output is correct |
3 |
Correct |
3 ms |
16984 KB |
Output is correct |
4 |
Correct |
4 ms |
16984 KB |
Output is correct |
5 |
Correct |
4 ms |
17236 KB |
Output is correct |
6 |
Correct |
4 ms |
16984 KB |
Output is correct |
7 |
Correct |
4 ms |
17240 KB |
Output is correct |
8 |
Correct |
3 ms |
16984 KB |
Output is correct |
9 |
Correct |
3 ms |
16984 KB |
Output is correct |
10 |
Correct |
3 ms |
16984 KB |
Output is correct |
11 |
Correct |
4 ms |
16984 KB |
Output is correct |
12 |
Correct |
4 ms |
16984 KB |
Output is correct |
13 |
Correct |
4 ms |
16984 KB |
Output is correct |
14 |
Correct |
4 ms |
16984 KB |
Output is correct |
15 |
Correct |
3 ms |
16984 KB |
Output is correct |
16 |
Correct |
5 ms |
17240 KB |
Output is correct |
17 |
Correct |
4 ms |
17236 KB |
Output is correct |
18 |
Correct |
3 ms |
16984 KB |
Output is correct |
19 |
Correct |
3 ms |
17012 KB |
Output is correct |
20 |
Correct |
4 ms |
16984 KB |
Output is correct |
21 |
Correct |
4 ms |
16984 KB |
Output is correct |
22 |
Correct |
4 ms |
16984 KB |
Output is correct |
23 |
Correct |
5 ms |
17236 KB |
Output is correct |
24 |
Correct |
4 ms |
17240 KB |
Output is correct |
25 |
Correct |
6 ms |
17240 KB |
Output is correct |
26 |
Correct |
5 ms |
17240 KB |
Output is correct |
27 |
Correct |
6 ms |
17240 KB |
Output is correct |
28 |
Correct |
5 ms |
17496 KB |
Output is correct |
29 |
Correct |
5 ms |
17240 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
16984 KB |
Output is correct |
2 |
Correct |
4 ms |
16984 KB |
Output is correct |
3 |
Correct |
3 ms |
16984 KB |
Output is correct |
4 |
Correct |
4 ms |
16984 KB |
Output is correct |
5 |
Correct |
4 ms |
17236 KB |
Output is correct |
6 |
Correct |
4 ms |
16984 KB |
Output is correct |
7 |
Correct |
4 ms |
17240 KB |
Output is correct |
8 |
Correct |
3 ms |
16984 KB |
Output is correct |
9 |
Correct |
3 ms |
16984 KB |
Output is correct |
10 |
Correct |
3 ms |
16984 KB |
Output is correct |
11 |
Correct |
4 ms |
16984 KB |
Output is correct |
12 |
Correct |
4 ms |
16984 KB |
Output is correct |
13 |
Correct |
4 ms |
16984 KB |
Output is correct |
14 |
Correct |
4 ms |
16984 KB |
Output is correct |
15 |
Correct |
3 ms |
16984 KB |
Output is correct |
16 |
Correct |
5 ms |
17240 KB |
Output is correct |
17 |
Correct |
4 ms |
17236 KB |
Output is correct |
18 |
Correct |
3 ms |
16984 KB |
Output is correct |
19 |
Correct |
3 ms |
17012 KB |
Output is correct |
20 |
Correct |
4 ms |
16984 KB |
Output is correct |
21 |
Correct |
4 ms |
16984 KB |
Output is correct |
22 |
Correct |
4 ms |
16984 KB |
Output is correct |
23 |
Correct |
5 ms |
17236 KB |
Output is correct |
24 |
Correct |
4 ms |
17240 KB |
Output is correct |
25 |
Correct |
6 ms |
17240 KB |
Output is correct |
26 |
Correct |
5 ms |
17240 KB |
Output is correct |
27 |
Correct |
6 ms |
17240 KB |
Output is correct |
28 |
Correct |
5 ms |
17496 KB |
Output is correct |
29 |
Correct |
5 ms |
17240 KB |
Output is correct |
30 |
Correct |
19 ms |
18788 KB |
Output is correct |
31 |
Correct |
7 ms |
17752 KB |
Output is correct |
32 |
Correct |
22 ms |
19936 KB |
Output is correct |
33 |
Correct |
20 ms |
18856 KB |
Output is correct |
34 |
Correct |
31 ms |
23124 KB |
Output is correct |
35 |
Correct |
31 ms |
20332 KB |
Output is correct |
36 |
Correct |
31 ms |
18976 KB |
Output is correct |
37 |
Correct |
26 ms |
19436 KB |
Output is correct |
38 |
Correct |
32 ms |
18940 KB |
Output is correct |
39 |
Correct |
28 ms |
19108 KB |
Output is correct |
40 |
Correct |
30 ms |
22572 KB |
Output is correct |
41 |
Correct |
30 ms |
19840 KB |
Output is correct |
42 |
Correct |
27 ms |
19972 KB |
Output is correct |
43 |
Correct |
42 ms |
20672 KB |
Output is correct |
44 |
Correct |
39 ms |
20628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
16984 KB |
Output is correct |
2 |
Correct |
4 ms |
16984 KB |
Output is correct |
3 |
Correct |
3 ms |
16984 KB |
Output is correct |
4 |
Correct |
4 ms |
16984 KB |
Output is correct |
5 |
Correct |
4 ms |
17236 KB |
Output is correct |
6 |
Correct |
4 ms |
16984 KB |
Output is correct |
7 |
Correct |
4 ms |
17240 KB |
Output is correct |
8 |
Correct |
3 ms |
16984 KB |
Output is correct |
9 |
Correct |
3 ms |
16984 KB |
Output is correct |
10 |
Correct |
3 ms |
16984 KB |
Output is correct |
11 |
Correct |
4 ms |
16984 KB |
Output is correct |
12 |
Correct |
4 ms |
16984 KB |
Output is correct |
13 |
Correct |
4 ms |
16984 KB |
Output is correct |
14 |
Correct |
4 ms |
16984 KB |
Output is correct |
15 |
Correct |
3 ms |
16984 KB |
Output is correct |
16 |
Correct |
5 ms |
17240 KB |
Output is correct |
17 |
Correct |
4 ms |
17236 KB |
Output is correct |
18 |
Correct |
3 ms |
16984 KB |
Output is correct |
19 |
Correct |
3 ms |
17012 KB |
Output is correct |
20 |
Correct |
4 ms |
16984 KB |
Output is correct |
21 |
Correct |
4 ms |
16984 KB |
Output is correct |
22 |
Correct |
4 ms |
16984 KB |
Output is correct |
23 |
Correct |
5 ms |
17236 KB |
Output is correct |
24 |
Correct |
4 ms |
17240 KB |
Output is correct |
25 |
Correct |
6 ms |
17240 KB |
Output is correct |
26 |
Correct |
5 ms |
17240 KB |
Output is correct |
27 |
Correct |
6 ms |
17240 KB |
Output is correct |
28 |
Correct |
5 ms |
17496 KB |
Output is correct |
29 |
Correct |
5 ms |
17240 KB |
Output is correct |
30 |
Correct |
19 ms |
18788 KB |
Output is correct |
31 |
Correct |
7 ms |
17752 KB |
Output is correct |
32 |
Correct |
22 ms |
19936 KB |
Output is correct |
33 |
Correct |
20 ms |
18856 KB |
Output is correct |
34 |
Correct |
31 ms |
23124 KB |
Output is correct |
35 |
Correct |
31 ms |
20332 KB |
Output is correct |
36 |
Correct |
31 ms |
18976 KB |
Output is correct |
37 |
Correct |
26 ms |
19436 KB |
Output is correct |
38 |
Correct |
32 ms |
18940 KB |
Output is correct |
39 |
Correct |
28 ms |
19108 KB |
Output is correct |
40 |
Correct |
30 ms |
22572 KB |
Output is correct |
41 |
Correct |
30 ms |
19840 KB |
Output is correct |
42 |
Correct |
27 ms |
19972 KB |
Output is correct |
43 |
Correct |
42 ms |
20672 KB |
Output is correct |
44 |
Correct |
39 ms |
20628 KB |
Output is correct |
45 |
Correct |
235 ms |
29568 KB |
Output is correct |
46 |
Correct |
9 ms |
18776 KB |
Output is correct |
47 |
Correct |
10 ms |
18520 KB |
Output is correct |
48 |
Correct |
379 ms |
44712 KB |
Output is correct |
49 |
Correct |
261 ms |
37688 KB |
Output is correct |
50 |
Correct |
729 ms |
51692 KB |
Output is correct |
51 |
Correct |
878 ms |
45668 KB |
Output is correct |
52 |
Correct |
592 ms |
36956 KB |
Output is correct |
53 |
Correct |
783 ms |
37324 KB |
Output is correct |
54 |
Correct |
849 ms |
36680 KB |
Output is correct |
55 |
Correct |
1164 ms |
37132 KB |
Output is correct |
56 |
Correct |
1206 ms |
37008 KB |
Output is correct |
57 |
Correct |
454 ms |
31104 KB |
Output is correct |
58 |
Correct |
473 ms |
30736 KB |
Output is correct |
59 |
Correct |
413 ms |
31756 KB |
Output is correct |
60 |
Correct |
454 ms |
31068 KB |
Output is correct |
61 |
Correct |
476 ms |
31088 KB |
Output is correct |
62 |
Correct |
509 ms |
41232 KB |
Output is correct |
63 |
Correct |
393 ms |
37704 KB |
Output is correct |
64 |
Correct |
1186 ms |
64188 KB |
Output is correct |
65 |
Correct |
435 ms |
37936 KB |
Output is correct |
66 |
Correct |
336 ms |
33684 KB |
Output is correct |
67 |
Correct |
632 ms |
43648 KB |
Output is correct |
68 |
Correct |
165 ms |
27980 KB |
Output is correct |
69 |
Correct |
43 ms |
22084 KB |
Output is correct |
70 |
Correct |
673 ms |
42228 KB |
Output is correct |
71 |
Correct |
295 ms |
31132 KB |
Output is correct |
72 |
Correct |
208 ms |
26856 KB |
Output is correct |
73 |
Correct |
575 ms |
40260 KB |
Output is correct |
74 |
Correct |
1237 ms |
36884 KB |
Output is correct |
75 |
Correct |
1109 ms |
46936 KB |
Output is correct |
76 |
Correct |
1026 ms |
54620 KB |
Output is correct |