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
#define F first
#define S second
using namespace std;
const int M = 1e6 + 5, MOD = 1e9 + 7;
int N, K, col[M];
vector<int> g[M];
void init(int n, int k) {
N = n, K = k;
for(int i = 0; i < k - 1; ++i)
g[i].pb(i + 1);
}
bool dfs(int node){
col[node] = 1;
bool cur = 0;
for(auto k : g[node]){
if(col[k] == 0)
cur |= dfs(k);
else if(col[k] == 1){
if(k < K)
cur |= 1;
}
}
col[node] = 2;
return cur;
}
int add_teleporter(int u, int v) {
if(N == K){
if(u >= v)
return 1;
return 0;
}
if(u < K and v < K)
if(u >= v)
return 1;
for(int i = 0; i < N; ++i) col[i] = 0;
g[u].pb(v);
return dfs(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... |