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;
const int MAXN=3e5+6;
int min_nxt[MAXN];
vector<int>gr[MAXN];
int n,k;
void init(int _n, int _k) {
n=_n;k=_k;
for(int i=0;i<n;i++)
{
min_nxt[i]=n+1;
}
}
bool set_min(int u,int val)
{
min_nxt[u]=val;
if(u<k&&min_nxt[u]<=u)return 1;
for(auto xd:gr[u])
{
if(min_nxt[xd]>val)
{
bool flag=set_min(xd,val);
if(flag==1)return 1;
}
}
return 0;
}
int add_teleporter(int u, int v) {
gr[v].push_back(u);
if(u<k&&v<k)
{
if(u>=v)return 1;
else return 0;
}
if(v<k)
{
if(v>=min_nxt[u])return 0;
bool flag=set_min(u,v);
return flag;
}
else if(min_nxt[v]>=min_nxt[u])return 0;
bool flag=set_min(u,min_nxt[v]);
return flag;
}
# | 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... |