# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1113558 |
2024-11-16T17:59:23 Z |
_8_8_ |
Game (APIO22_game) |
C++17 |
|
4000 ms |
43944 KB |
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 12;
int n, k, s[N], t[N];
vector<int> g[N], gr[N];
void init(int nn, int kk) {
n = nn;
k = kk;
for(int i = k; i < n; i++) {
s[i] = -1, t[i] = k;
}
for(int i = 0; i < k; ++i) {
s[i] = t[i] = i;
}
}
int vis[N], timer;
void dfs(int v, int val) {
vis[v] = timer;
s[v] = max(s[v], val);
for(int to:g[v]) if(vis[to] != timer && s[to] < val) {
dfs(to, val);
}
}
void dfs1(int v, int val) {
t[v] = min(t[v], val);
for(int to:gr[v]) if(vis[to] != timer && t[to] > val) {
dfs1(to, val);
}
}
bool cyc = 0;
int add_teleporter(int u, int v) {
if(max(u, v) < k) {
if(u >= v) cyc = 1;
}
if(cyc) return 1;
g[u].push_back(v);
gr[v].push_back(u);
if(s[u] <= s[v] && t[u] <= t[v]) return 0;
timer++;
dfs(v, s[u]);
timer++;
dfs1(u, t[v]);
vis[v] = timer;
for(int i = k; i < n; i++) {
if(s[i] >= t[i]) {
cyc = 1;
return 1;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14416 KB |
Output is correct |
2 |
Correct |
10 ms |
14416 KB |
Output is correct |
3 |
Correct |
10 ms |
14584 KB |
Output is correct |
4 |
Correct |
11 ms |
14480 KB |
Output is correct |
5 |
Correct |
11 ms |
14556 KB |
Output is correct |
6 |
Correct |
11 ms |
14560 KB |
Output is correct |
7 |
Correct |
10 ms |
14416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14416 KB |
Output is correct |
2 |
Correct |
10 ms |
14416 KB |
Output is correct |
3 |
Correct |
10 ms |
14584 KB |
Output is correct |
4 |
Correct |
11 ms |
14480 KB |
Output is correct |
5 |
Correct |
11 ms |
14556 KB |
Output is correct |
6 |
Correct |
11 ms |
14560 KB |
Output is correct |
7 |
Correct |
10 ms |
14416 KB |
Output is correct |
8 |
Correct |
14 ms |
14416 KB |
Output is correct |
9 |
Correct |
10 ms |
14416 KB |
Output is correct |
10 |
Correct |
11 ms |
14416 KB |
Output is correct |
11 |
Correct |
10 ms |
14416 KB |
Output is correct |
12 |
Correct |
10 ms |
14416 KB |
Output is correct |
13 |
Correct |
11 ms |
14552 KB |
Output is correct |
14 |
Correct |
12 ms |
14416 KB |
Output is correct |
15 |
Correct |
11 ms |
14416 KB |
Output is correct |
16 |
Correct |
10 ms |
14416 KB |
Output is correct |
17 |
Correct |
11 ms |
14416 KB |
Output is correct |
18 |
Correct |
10 ms |
14416 KB |
Output is correct |
19 |
Correct |
10 ms |
14416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14416 KB |
Output is correct |
2 |
Correct |
10 ms |
14416 KB |
Output is correct |
3 |
Correct |
10 ms |
14584 KB |
Output is correct |
4 |
Correct |
11 ms |
14480 KB |
Output is correct |
5 |
Correct |
11 ms |
14556 KB |
Output is correct |
6 |
Correct |
11 ms |
14560 KB |
Output is correct |
7 |
Correct |
10 ms |
14416 KB |
Output is correct |
8 |
Correct |
14 ms |
14416 KB |
Output is correct |
9 |
Correct |
10 ms |
14416 KB |
Output is correct |
10 |
Correct |
11 ms |
14416 KB |
Output is correct |
11 |
Correct |
10 ms |
14416 KB |
Output is correct |
12 |
Correct |
10 ms |
14416 KB |
Output is correct |
13 |
Correct |
11 ms |
14552 KB |
Output is correct |
14 |
Correct |
12 ms |
14416 KB |
Output is correct |
15 |
Correct |
11 ms |
14416 KB |
Output is correct |
16 |
Correct |
10 ms |
14416 KB |
Output is correct |
17 |
Correct |
11 ms |
14416 KB |
Output is correct |
18 |
Correct |
10 ms |
14416 KB |
Output is correct |
19 |
Correct |
10 ms |
14416 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 |
10 ms |
14416 KB |
Output is correct |
24 |
Correct |
13 ms |
14396 KB |
Output is correct |
25 |
Correct |
13 ms |
14416 KB |
Output is correct |
26 |
Correct |
12 ms |
14416 KB |
Output is correct |
27 |
Correct |
14 ms |
14416 KB |
Output is correct |
28 |
Correct |
11 ms |
14552 KB |
Output is correct |
29 |
Correct |
13 ms |
14580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14416 KB |
Output is correct |
2 |
Correct |
10 ms |
14416 KB |
Output is correct |
3 |
Correct |
10 ms |
14584 KB |
Output is correct |
4 |
Correct |
11 ms |
14480 KB |
Output is correct |
5 |
Correct |
11 ms |
14556 KB |
Output is correct |
6 |
Correct |
11 ms |
14560 KB |
Output is correct |
7 |
Correct |
10 ms |
14416 KB |
Output is correct |
8 |
Correct |
14 ms |
14416 KB |
Output is correct |
9 |
Correct |
10 ms |
14416 KB |
Output is correct |
10 |
Correct |
11 ms |
14416 KB |
Output is correct |
11 |
Correct |
10 ms |
14416 KB |
Output is correct |
12 |
Correct |
10 ms |
14416 KB |
Output is correct |
13 |
Correct |
11 ms |
14552 KB |
Output is correct |
14 |
Correct |
12 ms |
14416 KB |
Output is correct |
15 |
Correct |
11 ms |
14416 KB |
Output is correct |
16 |
Correct |
10 ms |
14416 KB |
Output is correct |
17 |
Correct |
11 ms |
14416 KB |
Output is correct |
18 |
Correct |
10 ms |
14416 KB |
Output is correct |
19 |
Correct |
10 ms |
14416 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 |
10 ms |
14416 KB |
Output is correct |
24 |
Correct |
13 ms |
14396 KB |
Output is correct |
25 |
Correct |
13 ms |
14416 KB |
Output is correct |
26 |
Correct |
12 ms |
14416 KB |
Output is correct |
27 |
Correct |
14 ms |
14416 KB |
Output is correct |
28 |
Correct |
11 ms |
14552 KB |
Output is correct |
29 |
Correct |
13 ms |
14580 KB |
Output is correct |
30 |
Correct |
32 ms |
15948 KB |
Output is correct |
31 |
Correct |
20 ms |
15440 KB |
Output is correct |
32 |
Correct |
28 ms |
17232 KB |
Output is correct |
33 |
Correct |
27 ms |
16664 KB |
Output is correct |
34 |
Correct |
1133 ms |
18064 KB |
Output is correct |
35 |
Correct |
611 ms |
17480 KB |
Output is correct |
36 |
Correct |
119 ms |
16712 KB |
Output is correct |
37 |
Correct |
163 ms |
16808 KB |
Output is correct |
38 |
Correct |
305 ms |
16456 KB |
Output is correct |
39 |
Correct |
353 ms |
16456 KB |
Output is correct |
40 |
Correct |
1158 ms |
18548 KB |
Output is correct |
41 |
Correct |
464 ms |
17004 KB |
Output is correct |
42 |
Correct |
310 ms |
16964 KB |
Output is correct |
43 |
Correct |
124 ms |
18396 KB |
Output is correct |
44 |
Correct |
881 ms |
18088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14416 KB |
Output is correct |
2 |
Correct |
10 ms |
14416 KB |
Output is correct |
3 |
Correct |
10 ms |
14584 KB |
Output is correct |
4 |
Correct |
11 ms |
14480 KB |
Output is correct |
5 |
Correct |
11 ms |
14556 KB |
Output is correct |
6 |
Correct |
11 ms |
14560 KB |
Output is correct |
7 |
Correct |
10 ms |
14416 KB |
Output is correct |
8 |
Correct |
14 ms |
14416 KB |
Output is correct |
9 |
Correct |
10 ms |
14416 KB |
Output is correct |
10 |
Correct |
11 ms |
14416 KB |
Output is correct |
11 |
Correct |
10 ms |
14416 KB |
Output is correct |
12 |
Correct |
10 ms |
14416 KB |
Output is correct |
13 |
Correct |
11 ms |
14552 KB |
Output is correct |
14 |
Correct |
12 ms |
14416 KB |
Output is correct |
15 |
Correct |
11 ms |
14416 KB |
Output is correct |
16 |
Correct |
10 ms |
14416 KB |
Output is correct |
17 |
Correct |
11 ms |
14416 KB |
Output is correct |
18 |
Correct |
10 ms |
14416 KB |
Output is correct |
19 |
Correct |
10 ms |
14416 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 |
10 ms |
14416 KB |
Output is correct |
24 |
Correct |
13 ms |
14396 KB |
Output is correct |
25 |
Correct |
13 ms |
14416 KB |
Output is correct |
26 |
Correct |
12 ms |
14416 KB |
Output is correct |
27 |
Correct |
14 ms |
14416 KB |
Output is correct |
28 |
Correct |
11 ms |
14552 KB |
Output is correct |
29 |
Correct |
13 ms |
14580 KB |
Output is correct |
30 |
Correct |
32 ms |
15948 KB |
Output is correct |
31 |
Correct |
20 ms |
15440 KB |
Output is correct |
32 |
Correct |
28 ms |
17232 KB |
Output is correct |
33 |
Correct |
27 ms |
16664 KB |
Output is correct |
34 |
Correct |
1133 ms |
18064 KB |
Output is correct |
35 |
Correct |
611 ms |
17480 KB |
Output is correct |
36 |
Correct |
119 ms |
16712 KB |
Output is correct |
37 |
Correct |
163 ms |
16808 KB |
Output is correct |
38 |
Correct |
305 ms |
16456 KB |
Output is correct |
39 |
Correct |
353 ms |
16456 KB |
Output is correct |
40 |
Correct |
1158 ms |
18548 KB |
Output is correct |
41 |
Correct |
464 ms |
17004 KB |
Output is correct |
42 |
Correct |
310 ms |
16964 KB |
Output is correct |
43 |
Correct |
124 ms |
18396 KB |
Output is correct |
44 |
Correct |
881 ms |
18088 KB |
Output is correct |
45 |
Correct |
313 ms |
29180 KB |
Output is correct |
46 |
Correct |
25 ms |
17232 KB |
Output is correct |
47 |
Correct |
25 ms |
17244 KB |
Output is correct |
48 |
Correct |
364 ms |
43944 KB |
Output is correct |
49 |
Correct |
308 ms |
36848 KB |
Output is correct |
50 |
Execution timed out |
4059 ms |
33940 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |