// #include "game.h"
#include <vector>
using namespace std;
int N,K;
int const MAXN=300000+10;
vector<int>nei[MAXN]={};
bool vis[MAXN]={};
void init(int n, int k)
{
N=n,K=k;
for (int i=0;i<k-1;i++)
nei[i].push_back(i+1);
}
bool check_cycle(int n)
{
vis[n]=1;
for (auto i:nei[n])
{
if (vis[i]&&i<K)
return 1;
if (vis[i])
continue;
if (check_cycle(i))
return 1;
}
return 0;
}
int add_teleporter(int u, int v)
{
nei[u].push_back(v);
for (int i=0;i<=N;i++)
{
for (int j=0;j<=N;j++)
vis[j]=0;
if (check_cycle(i)) return 1;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
7256 KB |
Output is correct |
2 |
Incorrect |
3 ms |
7256 KB |
Wrong Answer[1] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
7256 KB |
Output is correct |
2 |
Incorrect |
3 ms |
7256 KB |
Wrong Answer[1] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
7256 KB |
Output is correct |
2 |
Incorrect |
3 ms |
7256 KB |
Wrong Answer[1] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
7256 KB |
Output is correct |
2 |
Incorrect |
3 ms |
7256 KB |
Wrong Answer[1] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
7256 KB |
Output is correct |
2 |
Incorrect |
3 ms |
7256 KB |
Wrong Answer[1] |
3 |
Halted |
0 ms |
0 KB |
- |