#include "game.h"
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
int N = 300000;
int K = -1;
bool done = false;
bool cyc = false;
vector<vector<int>> adj(N);
vector<bool> vis(N,false);
void init(int n, int k) {
N = n;
K = k;
for (int i=0; i<=k-2; i++) {
adj[i].push_back(i+1);
}
}
void dfs(int u) {
if (vis[u]) {
cyc = true;
return;
}
vis[u] = true;
for (auto &v:adj[u]) {
dfs(v);
}
}
int add_teleporter(int u, int v) {
adj[u].push_back(v);
if (done) return 1;
for (int i=0; i<N; i++) {
vis[i] = false;
}
cyc = false;
dfs(0);
if (cyc) return 1;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7376 KB |
Output is correct |
2 |
Incorrect |
4 ms |
7376 KB |
Wrong Answer[1] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7376 KB |
Output is correct |
2 |
Incorrect |
4 ms |
7376 KB |
Wrong Answer[1] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7376 KB |
Output is correct |
2 |
Incorrect |
4 ms |
7376 KB |
Wrong Answer[1] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7376 KB |
Output is correct |
2 |
Incorrect |
4 ms |
7376 KB |
Wrong Answer[1] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7376 KB |
Output is correct |
2 |
Incorrect |
4 ms |
7376 KB |
Wrong Answer[1] |
3 |
Halted |
0 ms |
0 KB |
- |