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 <bits/stdc++.h>
using namespace std;
const int N = 300000;
int K;
vector<int>adj[N];
vector<int>adj_[N];
int mn[N];
void init(int n, int k) {
K = k;
for (int i = 0; i < n; i++)
mn[i] = k;
}
int add_teleporter(int u, int v) {
adj[u].push_back(v);
adj_[v].push_back(u);
int x = min(v, mn[v]);
int ret = 0;
function<void(int)>dfs = [&](int i) {
if (x >= mn[i])
return;
mn[i] = x;
if (i < K && x <= i) {
ret = 1;
}
for (int j : adj_[i]) {
dfs(j);
}
};
dfs(u);
return ret;
}
# | 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... |