This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
const int nax = 30005;
const int kax = 1005;
int reach[kax][nax], N, K;
vector<int> G[nax];
bool ok;
void dfs(int tp, int u) {
reach[tp][u] = 1;
if (u <= tp) ok = true;
for (auto & v : G[u]) {
if (!reach[tp][v]) {
dfs(tp, v);
}
}
}
void init(int n, int k) {
N = n; K = k; ok = false;
for (int i = 1; i <= k - 1; i++) G[i].push_back(i + 1);
for (int i = 1; i <= k - 1; i++) dfs(i, i + 1);
}
int add_teleporter(int u, int v) {
u++; v++;
G[u].push_back(v);
for (int i = 1; i <= K; i++) {
if ((u == i || reach[i][u]) && !reach[i][v]) {
dfs(i, v);
}
}
return ok;
}
# | 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... |