#include "game.h"
#include "bits/stdc++.h"
using namespace std;
int n, k;
vector<queue<int>> g;
vector<bool> can;
void init(int _n, int _k) {
n = _n, k = _k;
can = vector(n, false);
for (int i = 0; i < k; i++) can[i] = true;
g.assign(n, queue<int>());
}
int add_teleporter(int u, int v) {
if (u < v and v < k) return 0;
g[u].push(v);
if (can[u]) {
queue<int> q;
while (!g[u].empty()) {
q.push(g[u].front());
g[u].pop();
}
while (!q.empty()) {
int v = q.front(); q.pop();
// cout << '\t' << v << endl;
can[v] = true;
if (v < k) return 1;
while (!g[v].empty()) {
q.push(g[v].front());
g[v].pop();
}
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |