# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
789684 |
2023-07-21T18:14:43 Z |
GusterGoose27 |
Game (APIO22_game) |
C++17 |
|
4000 ms |
41520 KB |
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5+5;
const int MAXB = 20;
vector<int> edges[MAXN];
vector<int> rev[MAXN];
int mxin[MAXN];
int mnout[MAXN];
int n, k;
bool rev_dfs(int cur) {
if (mnout[cur] <= mxin[cur]) return 1;
for (int nxt: rev[cur]) {
if (mnout[cur] < mnout[nxt]) {
mnout[nxt] = mnout[cur];
rev_dfs(nxt);
}
}
return 0;
}
bool dfs(int cur) {
if (mnout[cur] <= mxin[cur]) return 1;
for (int nxt: edges[cur]) {
if (mxin[cur] > mxin[nxt]) {
mxin[nxt] = mxin[cur];
dfs(nxt);
}
}
return 0;
}
bool add_edge(int u, int v) {
edges[u].push_back(v);
rev[v].push_back(u);
if (v < k && mnout[u] > v) {
mnout[u] = v;
if (rev_dfs(u)) return 1;
}
if (mnout[v] < mnout[u]) {
mnout[u] = mnout[v];
if (rev_dfs(u)) return 1;
}
if (mxin[u] > mxin[v]) {
mxin[v] = mxin[u];
if (dfs(v)) return 1;
}
return 0;
}
void init(int N, int K) {
n = N;
k = K;
fill(mxin, mxin+n, -1);
fill(mnout, mnout+n, n);
for (int i = 0; i < k; i++) {
mxin[i] = i; mnout[i] = i+1;
}
}
int add_teleporter(int u, int v) {
return add_edge(u, v);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
14416 KB |
Output is correct |
2 |
Correct |
6 ms |
14288 KB |
Output is correct |
3 |
Correct |
6 ms |
14288 KB |
Output is correct |
4 |
Correct |
6 ms |
14288 KB |
Output is correct |
5 |
Correct |
6 ms |
14308 KB |
Output is correct |
6 |
Correct |
6 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
14416 KB |
Output is correct |
2 |
Correct |
6 ms |
14288 KB |
Output is correct |
3 |
Correct |
6 ms |
14288 KB |
Output is correct |
4 |
Correct |
6 ms |
14288 KB |
Output is correct |
5 |
Correct |
6 ms |
14308 KB |
Output is correct |
6 |
Correct |
6 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
8 |
Correct |
6 ms |
14288 KB |
Output is correct |
9 |
Correct |
6 ms |
14324 KB |
Output is correct |
10 |
Correct |
6 ms |
14288 KB |
Output is correct |
11 |
Correct |
5 ms |
14288 KB |
Output is correct |
12 |
Correct |
6 ms |
14288 KB |
Output is correct |
13 |
Correct |
6 ms |
14392 KB |
Output is correct |
14 |
Correct |
6 ms |
14288 KB |
Output is correct |
15 |
Correct |
7 ms |
14404 KB |
Output is correct |
16 |
Correct |
6 ms |
14368 KB |
Output is correct |
17 |
Correct |
6 ms |
14320 KB |
Output is correct |
18 |
Correct |
6 ms |
14356 KB |
Output is correct |
19 |
Correct |
6 ms |
14368 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
14416 KB |
Output is correct |
2 |
Correct |
6 ms |
14288 KB |
Output is correct |
3 |
Correct |
6 ms |
14288 KB |
Output is correct |
4 |
Correct |
6 ms |
14288 KB |
Output is correct |
5 |
Correct |
6 ms |
14308 KB |
Output is correct |
6 |
Correct |
6 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
8 |
Correct |
6 ms |
14288 KB |
Output is correct |
9 |
Correct |
6 ms |
14324 KB |
Output is correct |
10 |
Correct |
6 ms |
14288 KB |
Output is correct |
11 |
Correct |
5 ms |
14288 KB |
Output is correct |
12 |
Correct |
6 ms |
14288 KB |
Output is correct |
13 |
Correct |
6 ms |
14392 KB |
Output is correct |
14 |
Correct |
6 ms |
14288 KB |
Output is correct |
15 |
Correct |
7 ms |
14404 KB |
Output is correct |
16 |
Correct |
6 ms |
14368 KB |
Output is correct |
17 |
Correct |
6 ms |
14320 KB |
Output is correct |
18 |
Correct |
6 ms |
14356 KB |
Output is correct |
19 |
Correct |
6 ms |
14368 KB |
Output is correct |
20 |
Correct |
7 ms |
14416 KB |
Output is correct |
21 |
Correct |
8 ms |
14288 KB |
Output is correct |
22 |
Correct |
7 ms |
14400 KB |
Output is correct |
23 |
Correct |
6 ms |
14416 KB |
Output is correct |
24 |
Correct |
9 ms |
14416 KB |
Output is correct |
25 |
Correct |
12 ms |
14416 KB |
Output is correct |
26 |
Correct |
8 ms |
14416 KB |
Output is correct |
27 |
Correct |
8 ms |
14484 KB |
Output is correct |
28 |
Correct |
7 ms |
14416 KB |
Output is correct |
29 |
Correct |
7 ms |
14416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
14416 KB |
Output is correct |
2 |
Correct |
6 ms |
14288 KB |
Output is correct |
3 |
Correct |
6 ms |
14288 KB |
Output is correct |
4 |
Correct |
6 ms |
14288 KB |
Output is correct |
5 |
Correct |
6 ms |
14308 KB |
Output is correct |
6 |
Correct |
6 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
8 |
Correct |
6 ms |
14288 KB |
Output is correct |
9 |
Correct |
6 ms |
14324 KB |
Output is correct |
10 |
Correct |
6 ms |
14288 KB |
Output is correct |
11 |
Correct |
5 ms |
14288 KB |
Output is correct |
12 |
Correct |
6 ms |
14288 KB |
Output is correct |
13 |
Correct |
6 ms |
14392 KB |
Output is correct |
14 |
Correct |
6 ms |
14288 KB |
Output is correct |
15 |
Correct |
7 ms |
14404 KB |
Output is correct |
16 |
Correct |
6 ms |
14368 KB |
Output is correct |
17 |
Correct |
6 ms |
14320 KB |
Output is correct |
18 |
Correct |
6 ms |
14356 KB |
Output is correct |
19 |
Correct |
6 ms |
14368 KB |
Output is correct |
20 |
Correct |
7 ms |
14416 KB |
Output is correct |
21 |
Correct |
8 ms |
14288 KB |
Output is correct |
22 |
Correct |
7 ms |
14400 KB |
Output is correct |
23 |
Correct |
6 ms |
14416 KB |
Output is correct |
24 |
Correct |
9 ms |
14416 KB |
Output is correct |
25 |
Correct |
12 ms |
14416 KB |
Output is correct |
26 |
Correct |
8 ms |
14416 KB |
Output is correct |
27 |
Correct |
8 ms |
14484 KB |
Output is correct |
28 |
Correct |
7 ms |
14416 KB |
Output is correct |
29 |
Correct |
7 ms |
14416 KB |
Output is correct |
30 |
Correct |
20 ms |
15656 KB |
Output is correct |
31 |
Correct |
9 ms |
14928 KB |
Output is correct |
32 |
Correct |
19 ms |
16684 KB |
Output is correct |
33 |
Correct |
18 ms |
16412 KB |
Output is correct |
34 |
Correct |
906 ms |
17908 KB |
Output is correct |
35 |
Correct |
326 ms |
17128 KB |
Output is correct |
36 |
Correct |
30 ms |
16480 KB |
Output is correct |
37 |
Correct |
25 ms |
16348 KB |
Output is correct |
38 |
Correct |
28 ms |
16232 KB |
Output is correct |
39 |
Correct |
24 ms |
16200 KB |
Output is correct |
40 |
Correct |
729 ms |
17860 KB |
Output is correct |
41 |
Correct |
139 ms |
16616 KB |
Output is correct |
42 |
Correct |
98 ms |
16448 KB |
Output is correct |
43 |
Correct |
32 ms |
17252 KB |
Output is correct |
44 |
Correct |
678 ms |
17864 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
14416 KB |
Output is correct |
2 |
Correct |
6 ms |
14288 KB |
Output is correct |
3 |
Correct |
6 ms |
14288 KB |
Output is correct |
4 |
Correct |
6 ms |
14288 KB |
Output is correct |
5 |
Correct |
6 ms |
14308 KB |
Output is correct |
6 |
Correct |
6 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
8 |
Correct |
6 ms |
14288 KB |
Output is correct |
9 |
Correct |
6 ms |
14324 KB |
Output is correct |
10 |
Correct |
6 ms |
14288 KB |
Output is correct |
11 |
Correct |
5 ms |
14288 KB |
Output is correct |
12 |
Correct |
6 ms |
14288 KB |
Output is correct |
13 |
Correct |
6 ms |
14392 KB |
Output is correct |
14 |
Correct |
6 ms |
14288 KB |
Output is correct |
15 |
Correct |
7 ms |
14404 KB |
Output is correct |
16 |
Correct |
6 ms |
14368 KB |
Output is correct |
17 |
Correct |
6 ms |
14320 KB |
Output is correct |
18 |
Correct |
6 ms |
14356 KB |
Output is correct |
19 |
Correct |
6 ms |
14368 KB |
Output is correct |
20 |
Correct |
7 ms |
14416 KB |
Output is correct |
21 |
Correct |
8 ms |
14288 KB |
Output is correct |
22 |
Correct |
7 ms |
14400 KB |
Output is correct |
23 |
Correct |
6 ms |
14416 KB |
Output is correct |
24 |
Correct |
9 ms |
14416 KB |
Output is correct |
25 |
Correct |
12 ms |
14416 KB |
Output is correct |
26 |
Correct |
8 ms |
14416 KB |
Output is correct |
27 |
Correct |
8 ms |
14484 KB |
Output is correct |
28 |
Correct |
7 ms |
14416 KB |
Output is correct |
29 |
Correct |
7 ms |
14416 KB |
Output is correct |
30 |
Correct |
20 ms |
15656 KB |
Output is correct |
31 |
Correct |
9 ms |
14928 KB |
Output is correct |
32 |
Correct |
19 ms |
16684 KB |
Output is correct |
33 |
Correct |
18 ms |
16412 KB |
Output is correct |
34 |
Correct |
906 ms |
17908 KB |
Output is correct |
35 |
Correct |
326 ms |
17128 KB |
Output is correct |
36 |
Correct |
30 ms |
16480 KB |
Output is correct |
37 |
Correct |
25 ms |
16348 KB |
Output is correct |
38 |
Correct |
28 ms |
16232 KB |
Output is correct |
39 |
Correct |
24 ms |
16200 KB |
Output is correct |
40 |
Correct |
729 ms |
17860 KB |
Output is correct |
41 |
Correct |
139 ms |
16616 KB |
Output is correct |
42 |
Correct |
98 ms |
16448 KB |
Output is correct |
43 |
Correct |
32 ms |
17252 KB |
Output is correct |
44 |
Correct |
678 ms |
17864 KB |
Output is correct |
45 |
Correct |
180 ms |
27988 KB |
Output is correct |
46 |
Correct |
12 ms |
17108 KB |
Output is correct |
47 |
Correct |
11 ms |
17104 KB |
Output is correct |
48 |
Correct |
243 ms |
41520 KB |
Output is correct |
49 |
Correct |
186 ms |
35400 KB |
Output is correct |
50 |
Execution timed out |
4056 ms |
33168 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |