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;
typedef long long ll;
#define vll vector<ll>
#define pll pair<ll,ll>
#define F first
#define S second
#define MAX 500005
vll vec[MAX];
ll n,pass[MAX],k;
stack<ll> q;
void init(int N, int K) {
n=N; k=K;
for(int i=0;i<k-1;i++)vec[i].push_back(i+1);
}
ll dfs(ll x,ll z){
pass[x]=z;ll r=0;
for(auto w : vec[x]){
if(pass[w]!=z)r=max(r,dfs(w,z));
else if(w==z)r=1;
}
return r;
}
int add_teleporter(int u, int v1) {
vec[u].push_back(v1);
for(int i=0;i<n;i++)pass[i]=0;
ll r=0;
for(int i=0;i<k;i++){
r=max(r,dfs(i,i));
}
return r;
}
# | 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... |