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>
#define pb push_back
using namespace std;
const int mxn = 300005;
vector<int>adj[mxn];
vector<bool>vis(mxn, 0);
int n,k;
bool ans;
void dfs(int x){
//cout<<x<<'\n';
if(ans)return;
if(vis[x]){
if(x < k){
//cout<<x<<"k"<<'\n';
ans = 1;
}
return;
}
vis[x] = 1;
for(auto u : adj[x])dfs(u);
}
void init(int N, int K) {
n = N;
k = K;
for(int i = 0; i<k-1; i++)adj[i].pb(i+1);
}
int add_teleporter(int u, int v) {
ans = 0;
adj[u].pb(v);
for(int i = 0;i<n;i++)vis[i] = 0;
dfs(0);
//cout<<ans<<'\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... |