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>
#include "game.h"
using namespace std;
#define REP(i, j, k) for (int i = (j); i < (k); i++)
#define RREP(i, j, k) for (int i = (j); i >= (k); i--)
template <class T>
inline bool mnto(T &a, const T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T &a, const T b) {return a < b ? a = b, 1 : 0;}
typedef long long ll;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int) x.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef tuple<int, int, int> iii;
#ifndef DEBUG
#define cerr if (0) cerr
#endif
const int MAXN = 300005;
const int INF = 1000000005;
const ll LINF = 1000000000000000005;
int n, k;
vi adj[MAXN], radj[MAXN];
int mn[MAXN], mx[MAXN];
bool ans;
void init(int N, int K) {
n = N; k = K;
REP (i, 0, k) {
mn[i] = mx[i] = i;
}
REP (i, k, n) {
mn[i] = INF; mx[i] = -INF;
}
}
void dfs(int u) {
if (u < k) {
return;
}
if (mn[u] <= mx[u]) {
ans = 1;
return;
}
for (int v : adj[u]) {
if (mxto(mx[v], mx[u])) {
dfs(v);
}
}
}
void rdfs(int u) {
if (u < k) {
return;
}
if (mn[u] <= mx[u]) {
ans = 1;
return;
}
for (int v : radj[u]) {
if (mnto(mn[v], mn[u])) {
rdfs(v);
}
}
}
int add_teleporter(int u, int v) {
if (u < k && v < k) {
if (v <= u) {
return 1;
} else {
return 0;
}
}
adj[u].pb(v);
if (mxto(mx[v], mx[u])) {
dfs(v);
}
radj[v].pb(u);
if (mnto(mn[u], mn[v])) {
rdfs(u);
}
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... |