#include "game.h"
#include <bits/stdc++.h>
#define maxn 300005
using namespace std;
int n, k;
int cl[30005][1005];
vector<int> adj[maxn];
void init(int n, int k) {
::n = n; ::k = k;
for (int i = 0; i < k-1; i++) adj[i].emplace_back(i+1);
for (int i = 0; i < k; i++) for (int j = 0; j <= i; j++) cl[i][j] = 1;
}
int add_teleporter(int u, int v) {
if (u == v && u < k) return 1;
if (u < k && v < k && v <= u) return 1;
adj[u].emplace_back(v);
for (int o = 0; o < k; o++) {
if (cl[u][o] && v == o) return 1;
if (cl[u][o] && !cl[v][o]) {
queue<int> q; q.emplace(v);
cl[v][o] = 1;
while (!q.empty()) {
int x = q.front(); q.pop();
for (int y : adj[x]) {
if (y <= o) return 1;
if (!cl[y][o]) {
cl[y][o] = 1;
q.emplace(y);
}
}
}
}
}
return 0;
}
/*
4 3 2
1 3
2 0
3 2
2
*/
# | 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... |