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;
int n, k, ret;
int st[300005], en[300005], diff[300005];
vector<int> adj[300005], rev[300005];
void func(int u) {
if(st[u]>=en[u]) ret = 1;
if(ret) return;
int d = __lg(st[u]^en[u]);
if(d<diff[u]) diff[u] = d;
else return;
for(int v:adj[u]) {
st[v] = max(st[v], st[u]);
func(v);
}
for(int v:rev[u]) {
en[v] = min(en[v], en[u]);
func(v);
}
}
void init(int N, int K) {
n = N; k = K;
for(int i=0;i<k;i++) {
st[i] = i;
en[i] = i+1;
}
for(int i=k;i<n;i++) {
st[i] = -1;
en[i] = k;
}
for(int i=0;i<n;i++) {
diff[i] = __lg(st[i]^en[i]);
}
}
int add_teleporter(int u, int v) {
adj[u].push_back(v);
rev[v].push_back(u);
st[v] = max(st[v], st[u]);
en[u] = min(en[u], en[v]);
if(u<k) st[v] = max(st[v], u);
if(v<k) en[u] = min(en[u], v);
func(v);
func(u);
return ret;
}
# | 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... |