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>
using namespace std;
#define pb push_back
vector<int> q[200100], dq[200100];
int n, k;
void init(int N, int K) {
n = N;
k = K;
for(int i=0; i<n; i++){
q[i].clear();
dq[i].clear();
}
for(int i=0; i<k-1; i++){
q[i].pb(i + 1);
dq[i + 1].pb(i);
}
}
int dp[200100], us[200100];
void dfs(int v){
us[v] = 1;
for(int to: q[v]){
if(!us[to]) dfs(to);
dp[v] = min(dp[v], dp[to]);
dp[v] = min(dp[v], to);
}
}
int add_teleporter(int u, int v) {
for(int i=0; i<n; i++){
us[i] = 0;
dp[i] = 1e9;
}
q[u].pb(v);
dq[v].pb(u);
for(int i=0; i<n; i++){
if(us[i]) continue;
dfs(i);
}
for(int i=0; i<k; i++){
if(dp[i] <= i) 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... |