This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3,unroll-loops")
#include "game.h"
#include<bits/stdc++.h>
using namespace std;
int const n_max=3e5+10;
int N,K;
bitset<n_max> visited;
vector<int> llen(n_max,n_max);
vector<int> node[n_max];
void init(int n, int k)
{
cin.tie(nullptr)->sync_with_stdio(false);
N=n;
K=k;
for(int i=0;i<k;i++)
{
visited[i]=true;
llen[i]=i;
}
}
int add_teleporter(int u, int v)
{
if(visited[u])
{
if(v<K&&llen[u]>=v)return 1;
queue<int> q;
if(!visited[v]||llen[v]<llen[u])q.push(v);
visited[v]=true;
while(!q.empty())
{
int cur=q.front();
llen[cur]=llen[u];
q.pop();
for(auto nxt:node[cur])
{
if(nxt<K&&llen[cur]>=nxt)return 1;
if(!visited[nxt]||llen[nxt]<llen[cur])
{
q.push(nxt);
}
}
}
}
else node[u].push_back(v);
return 0;
}
# | 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... |