#include "game.h"
#include <bits/stdc++.h>
using namespace std;
const int maxN = 3e5 + 20;
int block;
int max_in[maxN];
int min_out[maxN];
vector<int> adj1[maxN];
vector<int> adj2[maxN];
bool done = false;
int n, k;
void init(int _n, int _k) {
n = _n;
k = _k;
if (n > 30000) {
block = sqrt(k);
}
for (int i = 0; i < k; i++) {
max_in[i] = (i - 1) / block;
min_out[i] = i / block;
}
for (int i = k; i < n; i++) {
max_in[i] = -1 / block;
min_out[i] = k / block;
}
}
void update_in(int u, int val) {
if (done) {
return;
}
if (val <= max_in[u]) {
return;
}
max_in[u] = val;
if (max_in[u] >= min_out[u]) {
done = true;
return;
}
for (auto v: adj1[u]) {
update_in(v, val);
}
}
void update_out(int u, int val) {
if (done) {
return;
}
if (val >= min_out[u]) {
return;
}
min_out[u] = val;
if (max_in[u] >= min_out[u]) {
done = true;
return;
}
for (auto v: adj2[u]) {
update_out(v, val);
}
}
int add_teleporter(int u, int v) {
update_in(v, max(max_in[u], (u < k ? u : -1) / block));
update_out(u, min_out[v]);
adj1[u].push_back(v);
adj2[v].push_back(u);
return done;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
23 ms |
28940 KB |
Execution killed with signal 8 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
23 ms |
28940 KB |
Execution killed with signal 8 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
23 ms |
28940 KB |
Execution killed with signal 8 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
23 ms |
28940 KB |
Execution killed with signal 8 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
23 ms |
28940 KB |
Execution killed with signal 8 |
2 |
Halted |
0 ms |
0 KB |
- |