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 maxN = 3e5 + 20;
int max_in[maxN];
vector<int> adj[maxN];
int n, k;
void init(int _n, int _k) {
n = _n;
k = _k;
for (int i = 0; i < k; i++) {
max_in[i] = i - 1;
}
for (int i = k; i < n; i++) {
max_in[i] = -1;
}
}
void dfs(int u) {
for (auto v: adj[u]) {
if (max_in[u] > max_in[v]) {
max_in[v] = max_in[u];
dfs(v);
}
}
}
int add_teleporter(int u, int v) {
int cur = max(max_in[u], (u < k ? u : -1));
if (cur > max_in[v]) {
max_in[v] = cur;
dfs(v);
}
adj[u].push_back(v);
for (int i = 0; i < k; i++) {
if (max_in[i] >= i) {
return 1;
}
}
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... |