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
#define mp make_pair
const int MOD=1e9+7;
int n,k;
vector<int> adj[300001];
bool work;
bool vis[300001];
void init(int N,int K){
n=N;
k=K;
work=false;
for (int i=0;i<k-1;i++){
adj[i].pb(i+1);
}
}
void dfs(int x,int ori){
if (x==ori) work=true;
if (work) return;
if (vis[x]) return;
vis[x]=true;
for (auto i:adj[x]){
dfs(i,ori);
}
}
int add_teleporter(int u,int v){
adj[u].pb(v);
for (int i=0;i<n;i++) vis[i]=false;
for (int i=k-1;i>=0;i--){
for (auto j:adj[i]){
dfs(j,i);
if (work) 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... |