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 N = 3e5 + 5;
vector<int> g[N];
int max_n, max_k;
int aa[N];
bool isCycle = false;
void init(int n, int k)
{
max_n = n, max_k = k;
for(int i = 0; i < n; i++)
{
aa[i] = (i < k) ? i : -1;
}
}
void dfs(int node, int val)
{
if(aa[node] >= val)
{
return;
}
aa[node] = val;
for(int to: g[node])
{
if(to < max_k)
{
if(val >= to)
{
isCycle = true;
break;
}
continue;
}
dfs(to, val);
}
}
int add_teleporter(int u, int v)
{
g[u].push_back(v);
if((v < max_k && aa[u] >= v) || (u < max_k && v <= u))
{
return true;
}
if(aa[v] < aa[u])
{
dfs(v, aa[u]);
}
return isCycle;
}
# | 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... |