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;
#define pb push_back
const int mxN = (int)2e5+10;
int n, k, sm[mxN], bg[mxN];
vector<int> adj[mxN], radj[mxN];
void init(int N, int K) {
n = N; k = K;
for(int i = 0; i < k; i++)
sm[i]=bg[i] =i;
for(int i = k; i < n; i++)
sm[i] = n, bg[i] = -1;
}
void dfs(int s, int c, vector<int> adj[], bool ok){
if(ok){
//if(c>=k) return;
if(bg[s]>=c) return;
bg[s] = c;
}
else{
if(sm[s]<=c) return;
sm[s] = c;
}
for(auto u : adj[s]) dfs(u,c,adj,ok);
}
int add_teleporter(int u, int v) {
if(u>=v and u<k) return 1;
if(max(u,v)<k) return 0;
adj[u].pb(v), radj[v].pb(u);
dfs(u, sm[v], radj,0), dfs(v,bg[u], adj,1);
return (sm[v]<=bg[u] and bg[u]<k);
}
# | 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... |