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,l[300100],r[300100];
#define F(i,j,K) for(int i = j; i <= K; i++)
#define FR(i,j) for(auto i: j)
vector<int> adj[300100],radj[300100];
void init(int N, int k) {
K = k;
F(i,0,K) l[i]=i,r[i]=i+1;
F(i,K+1,N) l[i]=0,r[i]=K+1;
F(i,0,N) adj[i].clear(),radj[i].clear();
}
bool calc(int u,int v){
if (r[u]<=l[v]) return 0;
if (l[u]>=r[v]) return 1;
if (l[u]==l[v]&&r[u]==r[v]) return 0;
if (r[v]<=(l[u]+r[u])/2){
r[u]=(l[u]+r[u])/2;
FR(i,radj[u])
if (calc(i,u))
return 1;
FR(i,adj[u])
if(calc(u,i)) return 1;
} else if (l[u]>=(l[v]+r[v])/2){
l[v]=(l[v]+r[v])/2;
FR(i,adj[v]) if (calc(v,i)) return 1;
FR(i,radj[v]) if (calc(i,v)) return 1;
}
return 0;
}
int add_teleporter(int u, int v) {
u++;
if (v>=K)
v++;
adj[u].push_back(v);
radj[v].push_back(u);
return calc(u,v);
}
# | 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... |