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;
vector<int> adj[300005];
int st[300005],N,ans,K;
void dfs(int u)
{
// cout<<u<<" ";
if (st[u]!=0)
{
if (st[u]==1 and u<K) ans=1;
return;
}
st[u]=1;
for (auto v:adj[u]) dfs(v);
st[u]=2;
}
void init(int n, int k)
{
N=n;K=k;
for (int i=1;i<k;i++) adj[i-1].push_back(i);
}
int add_teleporter(int u, int v)
{
adj[u].push_back(v);
sort(adj[u].begin(),adj[u].end());
ans=0;
for (int i=0;i<N;i++) st[i]=0;
dfs(0);
// cout<<"\n";
return ans;
}
# | 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... |