#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define maxn 300005
int N, K;
vector<int> adj[maxn];
void init(int n, int k){
N = n, K = k;
for(int i = 0; i < k - 1; ++i) adj[i].pb(i + 1);
}
int add_teleporter(int u, int v){
adj[u].pb(v);
vector<bool> vis(N, 0);
queue<int> bfs;
bfs.push(0), vis[0] = 1;
while(bfs.size()){
int u = bfs.front(); bfs.pop();
for(auto v:adj[u]){
if(vis[v]){
if(v < K && u >= v) return 1;
continue;
}
bfs.push(v);
vis[v] = 1;
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
7248 KB |
Output is correct |
2 |
Correct |
4 ms |
7248 KB |
Output is correct |
3 |
Correct |
5 ms |
7248 KB |
Output is correct |
4 |
Correct |
4 ms |
7248 KB |
Output is correct |
5 |
Correct |
5 ms |
7248 KB |
Output is correct |
6 |
Correct |
6 ms |
7288 KB |
Output is correct |
7 |
Incorrect |
5 ms |
7248 KB |
Wrong Answer[1] |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
7248 KB |
Output is correct |
2 |
Correct |
4 ms |
7248 KB |
Output is correct |
3 |
Correct |
5 ms |
7248 KB |
Output is correct |
4 |
Correct |
4 ms |
7248 KB |
Output is correct |
5 |
Correct |
5 ms |
7248 KB |
Output is correct |
6 |
Correct |
6 ms |
7288 KB |
Output is correct |
7 |
Incorrect |
5 ms |
7248 KB |
Wrong Answer[1] |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
7248 KB |
Output is correct |
2 |
Correct |
4 ms |
7248 KB |
Output is correct |
3 |
Correct |
5 ms |
7248 KB |
Output is correct |
4 |
Correct |
4 ms |
7248 KB |
Output is correct |
5 |
Correct |
5 ms |
7248 KB |
Output is correct |
6 |
Correct |
6 ms |
7288 KB |
Output is correct |
7 |
Incorrect |
5 ms |
7248 KB |
Wrong Answer[1] |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
7248 KB |
Output is correct |
2 |
Correct |
4 ms |
7248 KB |
Output is correct |
3 |
Correct |
5 ms |
7248 KB |
Output is correct |
4 |
Correct |
4 ms |
7248 KB |
Output is correct |
5 |
Correct |
5 ms |
7248 KB |
Output is correct |
6 |
Correct |
6 ms |
7288 KB |
Output is correct |
7 |
Incorrect |
5 ms |
7248 KB |
Wrong Answer[1] |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
7248 KB |
Output is correct |
2 |
Correct |
4 ms |
7248 KB |
Output is correct |
3 |
Correct |
5 ms |
7248 KB |
Output is correct |
4 |
Correct |
4 ms |
7248 KB |
Output is correct |
5 |
Correct |
5 ms |
7248 KB |
Output is correct |
6 |
Correct |
6 ms |
7288 KB |
Output is correct |
7 |
Incorrect |
5 ms |
7248 KB |
Wrong Answer[1] |
8 |
Halted |
0 ms |
0 KB |
- |