#include "game.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
// #define int ll
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n+1)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)((x).size())
namespace{
int n, kay;
const ll maxn = 3e4+5;
const ll maxk = 1005;
const ll mod = 1e9+7;
const ll inf = (1ll<<60);
vector<int> g[maxn];
vector<int> rg[maxn];
bool ioth[maxk][maxn];
bool othi[maxk][maxn]; // walk reverse graph
}
void init(int N, int K) {
n = N; kay = K;
/*REP(i, k-2){
g[i].pb(i+1);
rg[i+1].pb(i);
}
REP(i, k){
FOR(j, i, k){
ioth[i][j] = 1;
}
FOR(j, 0, i+1){
othi[i][j] = 1;
}
}
*/
}
bool dfs(int st, bool wh, int u){ // wh = 0: g, wh = 1, rg
if (wh == 0){
ioth[st][u] = 1;
if (othi[st][u]){
return 1;
}
for (auto v:g[u]){
if (ioth[st][v]) continue;
if (dfs(st, wh, v)) return 1;
}
return 0;
}
else{
othi[st][u] = 1;
if (ioth[st][u]){
return 1;
}
for (auto v:rg[u]){
if (othi[st][v]) continue;
if (dfs(st, wh, v)) return 1;
}
return 0;
}
}
int add_teleporter(int u, int v) {
// self-loop: u = v
if (u == v){
if (u < kay) return 1;
else return 0;
}
if (u > v) return 1;
else return 0;
}
/*
4 3 4
0 2
0 3
1 3
2 0
1 1
*/
# | 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... |