# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
821568 |
2023-08-11T11:40:42 Z |
radaiosm7 |
Game (APIO22_game) |
C++17 |
|
4000 ms |
3708 KB |
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> adj[30005];
int visited[30005];
int ind[30005];
int i, n, k, s;
int seg[120020];
int Query(int from, int to, int start=0, int ende=30005, int indx=1) {
if (from == start && to == ende) return seg[indx];
int mid = (start+ende)/2;
if (to <= mid) return Query(from, to, start, mid, 2*indx);
if (from > mid) return Query(from, to, mid+1, ende, 2*indx+1);
else return min(Query(from, mid, start, mid, 2*indx), Query(mid+1, to, mid+1, ende, 2*indx+1));
}
void Insert(int val, int start=0, int ende=30005, int indx=1) {
if (start == ende) {
seg[indx] = val;
ind[val] = s;
++s;
return;
}
int mid = (start+ende)/2;
if (s <= mid) Insert(val, start, mid, 2*indx);
else Insert(val, mid+1, ende, 2*indx+1);
seg[indx] = min(seg[2*indx], seg[2*indx+1]);
}
void Erase(int start=0, int ende=30005, int indx=1) {
if (start == ende) {
ind[seg[indx]] = -2;
seg[indx] = INT_MAX;
--s;
return;
}
int mid = (start+ende)/2;
if (s-1 <= mid) Erase(start, mid, 2*indx);
else Erase(mid+1, ende, 2*indx+1);
seg[indx] = min(seg[2*indx], seg[2*indx+1]);
}
void build(int start=0, int ende=30005, int indx=1) {
if (start == ende) {
seg[indx] = INT_MAX;
return;
}
int mid = (start+ende)/2;
build(start, mid, 2*indx);
build(mid+1, ende, 2*indx+1);
seg[indx] = min(seg[2*indx], seg[2*indx+1]);
}
void init(int N, int K) {
n = N;
k = K;
for (i=0; i < k-1; ++i) adj[i].push_back(i+1);
build();
}
bool dfs(int x) {
Insert(x);
bool ok = false;
for (auto y : adj[x]) {
if (ind[y] == -2) continue;
else if (ind[y] == -1) ok |= dfs(y);
else if (Query(ind[y], ind[x]) < k) return true;
if (ok) break;
}
Erase();
return ok;
}
int add_teleporter(int u, int v) {
fill(ind, ind+n, -1);
if (u == v) return (u < k) ? 1 : 0;
adj[u].push_back(v);
s = 0;
Insert(u);
if (dfs(v)) return 1;
else Erase();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1232 KB |
Output is correct |
2 |
Correct |
1 ms |
1232 KB |
Output is correct |
3 |
Correct |
2 ms |
1232 KB |
Output is correct |
4 |
Correct |
1 ms |
1232 KB |
Output is correct |
5 |
Correct |
2 ms |
1232 KB |
Output is correct |
6 |
Correct |
2 ms |
1232 KB |
Output is correct |
7 |
Correct |
2 ms |
1232 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1232 KB |
Output is correct |
2 |
Correct |
1 ms |
1232 KB |
Output is correct |
3 |
Correct |
2 ms |
1232 KB |
Output is correct |
4 |
Correct |
1 ms |
1232 KB |
Output is correct |
5 |
Correct |
2 ms |
1232 KB |
Output is correct |
6 |
Correct |
2 ms |
1232 KB |
Output is correct |
7 |
Correct |
2 ms |
1232 KB |
Output is correct |
8 |
Correct |
1 ms |
1232 KB |
Output is correct |
9 |
Correct |
1 ms |
1232 KB |
Output is correct |
10 |
Correct |
1 ms |
1232 KB |
Output is correct |
11 |
Correct |
1 ms |
1232 KB |
Output is correct |
12 |
Correct |
1 ms |
1232 KB |
Output is correct |
13 |
Correct |
1 ms |
1232 KB |
Output is correct |
14 |
Correct |
1 ms |
1172 KB |
Output is correct |
15 |
Correct |
1 ms |
1232 KB |
Output is correct |
16 |
Correct |
1 ms |
1232 KB |
Output is correct |
17 |
Correct |
1 ms |
1232 KB |
Output is correct |
18 |
Correct |
1 ms |
1232 KB |
Output is correct |
19 |
Correct |
1 ms |
1232 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1232 KB |
Output is correct |
2 |
Correct |
1 ms |
1232 KB |
Output is correct |
3 |
Correct |
2 ms |
1232 KB |
Output is correct |
4 |
Correct |
1 ms |
1232 KB |
Output is correct |
5 |
Correct |
2 ms |
1232 KB |
Output is correct |
6 |
Correct |
2 ms |
1232 KB |
Output is correct |
7 |
Correct |
2 ms |
1232 KB |
Output is correct |
8 |
Correct |
1 ms |
1232 KB |
Output is correct |
9 |
Correct |
1 ms |
1232 KB |
Output is correct |
10 |
Correct |
1 ms |
1232 KB |
Output is correct |
11 |
Correct |
1 ms |
1232 KB |
Output is correct |
12 |
Correct |
1 ms |
1232 KB |
Output is correct |
13 |
Correct |
1 ms |
1232 KB |
Output is correct |
14 |
Correct |
1 ms |
1172 KB |
Output is correct |
15 |
Correct |
1 ms |
1232 KB |
Output is correct |
16 |
Correct |
1 ms |
1232 KB |
Output is correct |
17 |
Correct |
1 ms |
1232 KB |
Output is correct |
18 |
Correct |
1 ms |
1232 KB |
Output is correct |
19 |
Correct |
1 ms |
1232 KB |
Output is correct |
20 |
Correct |
2 ms |
1232 KB |
Output is correct |
21 |
Correct |
1 ms |
1232 KB |
Output is correct |
22 |
Correct |
2 ms |
1304 KB |
Output is correct |
23 |
Correct |
2 ms |
1232 KB |
Output is correct |
24 |
Correct |
30 ms |
1232 KB |
Output is correct |
25 |
Correct |
128 ms |
1304 KB |
Output is correct |
26 |
Correct |
72 ms |
1312 KB |
Output is correct |
27 |
Correct |
9 ms |
1308 KB |
Output is correct |
28 |
Correct |
69 ms |
1316 KB |
Output is correct |
29 |
Correct |
119 ms |
1312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1232 KB |
Output is correct |
2 |
Correct |
1 ms |
1232 KB |
Output is correct |
3 |
Correct |
2 ms |
1232 KB |
Output is correct |
4 |
Correct |
1 ms |
1232 KB |
Output is correct |
5 |
Correct |
2 ms |
1232 KB |
Output is correct |
6 |
Correct |
2 ms |
1232 KB |
Output is correct |
7 |
Correct |
2 ms |
1232 KB |
Output is correct |
8 |
Correct |
1 ms |
1232 KB |
Output is correct |
9 |
Correct |
1 ms |
1232 KB |
Output is correct |
10 |
Correct |
1 ms |
1232 KB |
Output is correct |
11 |
Correct |
1 ms |
1232 KB |
Output is correct |
12 |
Correct |
1 ms |
1232 KB |
Output is correct |
13 |
Correct |
1 ms |
1232 KB |
Output is correct |
14 |
Correct |
1 ms |
1172 KB |
Output is correct |
15 |
Correct |
1 ms |
1232 KB |
Output is correct |
16 |
Correct |
1 ms |
1232 KB |
Output is correct |
17 |
Correct |
1 ms |
1232 KB |
Output is correct |
18 |
Correct |
1 ms |
1232 KB |
Output is correct |
19 |
Correct |
1 ms |
1232 KB |
Output is correct |
20 |
Correct |
2 ms |
1232 KB |
Output is correct |
21 |
Correct |
1 ms |
1232 KB |
Output is correct |
22 |
Correct |
2 ms |
1304 KB |
Output is correct |
23 |
Correct |
2 ms |
1232 KB |
Output is correct |
24 |
Correct |
30 ms |
1232 KB |
Output is correct |
25 |
Correct |
128 ms |
1304 KB |
Output is correct |
26 |
Correct |
72 ms |
1312 KB |
Output is correct |
27 |
Correct |
9 ms |
1308 KB |
Output is correct |
28 |
Correct |
69 ms |
1316 KB |
Output is correct |
29 |
Correct |
119 ms |
1312 KB |
Output is correct |
30 |
Correct |
76 ms |
1924 KB |
Output is correct |
31 |
Correct |
39 ms |
1620 KB |
Output is correct |
32 |
Correct |
97 ms |
2960 KB |
Output is correct |
33 |
Correct |
93 ms |
2312 KB |
Output is correct |
34 |
Correct |
2831 ms |
3708 KB |
Output is correct |
35 |
Execution timed out |
4017 ms |
2308 KB |
Time limit exceeded |
36 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1232 KB |
Output is correct |
2 |
Correct |
1 ms |
1232 KB |
Output is correct |
3 |
Correct |
2 ms |
1232 KB |
Output is correct |
4 |
Correct |
1 ms |
1232 KB |
Output is correct |
5 |
Correct |
2 ms |
1232 KB |
Output is correct |
6 |
Correct |
2 ms |
1232 KB |
Output is correct |
7 |
Correct |
2 ms |
1232 KB |
Output is correct |
8 |
Correct |
1 ms |
1232 KB |
Output is correct |
9 |
Correct |
1 ms |
1232 KB |
Output is correct |
10 |
Correct |
1 ms |
1232 KB |
Output is correct |
11 |
Correct |
1 ms |
1232 KB |
Output is correct |
12 |
Correct |
1 ms |
1232 KB |
Output is correct |
13 |
Correct |
1 ms |
1232 KB |
Output is correct |
14 |
Correct |
1 ms |
1172 KB |
Output is correct |
15 |
Correct |
1 ms |
1232 KB |
Output is correct |
16 |
Correct |
1 ms |
1232 KB |
Output is correct |
17 |
Correct |
1 ms |
1232 KB |
Output is correct |
18 |
Correct |
1 ms |
1232 KB |
Output is correct |
19 |
Correct |
1 ms |
1232 KB |
Output is correct |
20 |
Correct |
2 ms |
1232 KB |
Output is correct |
21 |
Correct |
1 ms |
1232 KB |
Output is correct |
22 |
Correct |
2 ms |
1304 KB |
Output is correct |
23 |
Correct |
2 ms |
1232 KB |
Output is correct |
24 |
Correct |
30 ms |
1232 KB |
Output is correct |
25 |
Correct |
128 ms |
1304 KB |
Output is correct |
26 |
Correct |
72 ms |
1312 KB |
Output is correct |
27 |
Correct |
9 ms |
1308 KB |
Output is correct |
28 |
Correct |
69 ms |
1316 KB |
Output is correct |
29 |
Correct |
119 ms |
1312 KB |
Output is correct |
30 |
Correct |
76 ms |
1924 KB |
Output is correct |
31 |
Correct |
39 ms |
1620 KB |
Output is correct |
32 |
Correct |
97 ms |
2960 KB |
Output is correct |
33 |
Correct |
93 ms |
2312 KB |
Output is correct |
34 |
Correct |
2831 ms |
3708 KB |
Output is correct |
35 |
Execution timed out |
4017 ms |
2308 KB |
Time limit exceeded |
36 |
Halted |
0 ms |
0 KB |
- |