# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
821366 |
2023-08-11T09:34:33 Z |
radaiosm7 |
Game (APIO22_game) |
C++17 |
|
82 ms |
444 KB |
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> adj[1005];
int visited[1005];
int ind[1005];
int i, n, k, s;
int seg[4020];
int Query(int from, int to, int start=0, int ende=1005, 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=1005, 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=1005, 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=1005, 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 |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
0 ms |
336 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
0 ms |
336 KB |
Output is correct |
12 |
Correct |
0 ms |
336 KB |
Output is correct |
13 |
Correct |
0 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
0 ms |
336 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
0 ms |
336 KB |
Output is correct |
12 |
Correct |
0 ms |
336 KB |
Output is correct |
13 |
Correct |
0 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
360 KB |
Output is correct |
21 |
Correct |
0 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 |
18 ms |
336 KB |
Output is correct |
25 |
Correct |
82 ms |
336 KB |
Output is correct |
26 |
Correct |
50 ms |
380 KB |
Output is correct |
27 |
Correct |
7 ms |
336 KB |
Output is correct |
28 |
Correct |
40 ms |
336 KB |
Output is correct |
29 |
Correct |
81 ms |
392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
0 ms |
336 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
0 ms |
336 KB |
Output is correct |
12 |
Correct |
0 ms |
336 KB |
Output is correct |
13 |
Correct |
0 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
360 KB |
Output is correct |
21 |
Correct |
0 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 |
18 ms |
336 KB |
Output is correct |
25 |
Correct |
82 ms |
336 KB |
Output is correct |
26 |
Correct |
50 ms |
380 KB |
Output is correct |
27 |
Correct |
7 ms |
336 KB |
Output is correct |
28 |
Correct |
40 ms |
336 KB |
Output is correct |
29 |
Correct |
81 ms |
392 KB |
Output is correct |
30 |
Runtime error |
1 ms |
444 KB |
Execution killed with signal 11 |
31 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
0 ms |
336 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
0 ms |
336 KB |
Output is correct |
12 |
Correct |
0 ms |
336 KB |
Output is correct |
13 |
Correct |
0 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
360 KB |
Output is correct |
21 |
Correct |
0 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 |
18 ms |
336 KB |
Output is correct |
25 |
Correct |
82 ms |
336 KB |
Output is correct |
26 |
Correct |
50 ms |
380 KB |
Output is correct |
27 |
Correct |
7 ms |
336 KB |
Output is correct |
28 |
Correct |
40 ms |
336 KB |
Output is correct |
29 |
Correct |
81 ms |
392 KB |
Output is correct |
30 |
Runtime error |
1 ms |
444 KB |
Execution killed with signal 11 |
31 |
Halted |
0 ms |
0 KB |
- |