# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
983485 |
2024-05-15T14:52:50 Z |
sleepntsheep |
Game (APIO22_game) |
C++17 |
|
8 ms |
21692 KB |
#include "game.h"
#include <string>
#include <algorithm>
#define N 300000
std::basic_string<int> g[N], gt[N];
int n, k, from[N], to[N], cyclic, lvl[N];
int msb(int x) {
return x ? 0 : 1 + msb(x >> 1);
}
void init(int n_, int k_) {
n = n_, k = k_;
for (int i = 0; i < k; ++i)
to[i] = i, from[i] = i + 1;
for (int i = k; i < n; ++i)
from[i] = k, to[i] = -1;
for (int i = 0; i < n; ++i)
lvl[i] = msb(from[i] ^ to[i]);
}
void check(int u) {
if (to[u] >= from[u] || cyclic) {
cyclic = 86;
return;
}
int d = msb(from[u] ^ to[u]);
if (d > lvl[u]) {
lvl[u] = d;
for (auto v : g[u]) {
to[v] = std::max(to[v], to[u]);
check(v);
}
for (auto v : gt[u]) {
from[v] = std::min(from[v], from[u]);
check(v);
}
}
}
int add_teleporter(int u, int v) {
if (cyclic)
return 1;
g[u].push_back(v);
gt[v].push_back(u);
to[v] = std::max(to[v], to[u]);
from[u] = std::min(from[u], from[v]);
if (u < k) to[v] = std::max(to[v], u);
if (v < k) from[u] = std::min(from[u], v);
check(u);
check(v);
return !!cyclic;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
21592 KB |
Output is correct |
2 |
Correct |
4 ms |
21592 KB |
Output is correct |
3 |
Correct |
6 ms |
21592 KB |
Output is correct |
4 |
Correct |
5 ms |
21592 KB |
Output is correct |
5 |
Correct |
4 ms |
21592 KB |
Output is correct |
6 |
Correct |
5 ms |
21692 KB |
Output is correct |
7 |
Correct |
5 ms |
21592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
21592 KB |
Output is correct |
2 |
Correct |
4 ms |
21592 KB |
Output is correct |
3 |
Correct |
6 ms |
21592 KB |
Output is correct |
4 |
Correct |
5 ms |
21592 KB |
Output is correct |
5 |
Correct |
4 ms |
21592 KB |
Output is correct |
6 |
Correct |
5 ms |
21692 KB |
Output is correct |
7 |
Correct |
5 ms |
21592 KB |
Output is correct |
8 |
Correct |
5 ms |
21592 KB |
Output is correct |
9 |
Correct |
4 ms |
21592 KB |
Output is correct |
10 |
Correct |
4 ms |
21592 KB |
Output is correct |
11 |
Incorrect |
4 ms |
21592 KB |
Wrong Answer[1] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
21592 KB |
Output is correct |
2 |
Correct |
4 ms |
21592 KB |
Output is correct |
3 |
Correct |
6 ms |
21592 KB |
Output is correct |
4 |
Correct |
5 ms |
21592 KB |
Output is correct |
5 |
Correct |
4 ms |
21592 KB |
Output is correct |
6 |
Correct |
5 ms |
21692 KB |
Output is correct |
7 |
Correct |
5 ms |
21592 KB |
Output is correct |
8 |
Correct |
5 ms |
21592 KB |
Output is correct |
9 |
Correct |
4 ms |
21592 KB |
Output is correct |
10 |
Correct |
4 ms |
21592 KB |
Output is correct |
11 |
Incorrect |
4 ms |
21592 KB |
Wrong Answer[1] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
21592 KB |
Output is correct |
2 |
Correct |
4 ms |
21592 KB |
Output is correct |
3 |
Correct |
6 ms |
21592 KB |
Output is correct |
4 |
Correct |
5 ms |
21592 KB |
Output is correct |
5 |
Correct |
4 ms |
21592 KB |
Output is correct |
6 |
Correct |
5 ms |
21692 KB |
Output is correct |
7 |
Correct |
5 ms |
21592 KB |
Output is correct |
8 |
Correct |
5 ms |
21592 KB |
Output is correct |
9 |
Correct |
4 ms |
21592 KB |
Output is correct |
10 |
Correct |
4 ms |
21592 KB |
Output is correct |
11 |
Incorrect |
4 ms |
21592 KB |
Wrong Answer[1] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
21592 KB |
Output is correct |
2 |
Correct |
4 ms |
21592 KB |
Output is correct |
3 |
Correct |
6 ms |
21592 KB |
Output is correct |
4 |
Correct |
5 ms |
21592 KB |
Output is correct |
5 |
Correct |
4 ms |
21592 KB |
Output is correct |
6 |
Correct |
5 ms |
21692 KB |
Output is correct |
7 |
Correct |
5 ms |
21592 KB |
Output is correct |
8 |
Correct |
5 ms |
21592 KB |
Output is correct |
9 |
Correct |
4 ms |
21592 KB |
Output is correct |
10 |
Correct |
4 ms |
21592 KB |
Output is correct |
11 |
Incorrect |
4 ms |
21592 KB |
Wrong Answer[1] |
12 |
Halted |
0 ms |
0 KB |
- |