#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define maxn 300005
int N, K, good = 0, t = 1, low[maxn];
vector<int> adj[maxn], rev[maxn];
void init(int n, int k){
N = n, K = k;
for(int i = 0; i < k - 1; ++i) adj[i].pb(i + 1), rev[i + 1].pb(i);
for(int i = 0; i < n; ++i) low[i] = i;
}
int add_teleporter(int u, int v){
if(u == v){
if(u < K) return 1;
else return 0;
}
bool ok = 1;
adj[u].pb(v);
rev[v].pb(u);
low[u] = min(low[v], low[u]);
queue<int> bfs; bfs.push(u);
while(bfs.size()){
int u = bfs.front(); bfs.pop();
for(auto v:rev[u]){
if(low[v] > low[u]) {
low[v] = low[u];
bfs.push(v);
if(v < K && low[v] < v) return 1;
}
}
}
if(u < K && low[u] < u) return 1;
return 0;
}
Compilation message
game.cpp: In function 'int add_teleporter(int, int)':
game.cpp:21:10: warning: unused variable 'ok' [-Wunused-variable]
21 | bool ok = 1;
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
10 ms |
14288 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
8 ms |
14288 KB |
Output is correct |
6 |
Correct |
7 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
10 ms |
14288 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
8 ms |
14288 KB |
Output is correct |
6 |
Correct |
7 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
8 |
Correct |
7 ms |
14288 KB |
Output is correct |
9 |
Correct |
8 ms |
14348 KB |
Output is correct |
10 |
Correct |
8 ms |
14288 KB |
Output is correct |
11 |
Correct |
8 ms |
14288 KB |
Output is correct |
12 |
Correct |
7 ms |
14288 KB |
Output is correct |
13 |
Incorrect |
8 ms |
14288 KB |
Wrong Answer[1] |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
10 ms |
14288 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
8 ms |
14288 KB |
Output is correct |
6 |
Correct |
7 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
8 |
Correct |
7 ms |
14288 KB |
Output is correct |
9 |
Correct |
8 ms |
14348 KB |
Output is correct |
10 |
Correct |
8 ms |
14288 KB |
Output is correct |
11 |
Correct |
8 ms |
14288 KB |
Output is correct |
12 |
Correct |
7 ms |
14288 KB |
Output is correct |
13 |
Incorrect |
8 ms |
14288 KB |
Wrong Answer[1] |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
10 ms |
14288 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
8 ms |
14288 KB |
Output is correct |
6 |
Correct |
7 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
8 |
Correct |
7 ms |
14288 KB |
Output is correct |
9 |
Correct |
8 ms |
14348 KB |
Output is correct |
10 |
Correct |
8 ms |
14288 KB |
Output is correct |
11 |
Correct |
8 ms |
14288 KB |
Output is correct |
12 |
Correct |
7 ms |
14288 KB |
Output is correct |
13 |
Incorrect |
8 ms |
14288 KB |
Wrong Answer[1] |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
14288 KB |
Output is correct |
2 |
Correct |
8 ms |
14288 KB |
Output is correct |
3 |
Correct |
10 ms |
14288 KB |
Output is correct |
4 |
Correct |
8 ms |
14288 KB |
Output is correct |
5 |
Correct |
8 ms |
14288 KB |
Output is correct |
6 |
Correct |
7 ms |
14288 KB |
Output is correct |
7 |
Correct |
7 ms |
14288 KB |
Output is correct |
8 |
Correct |
7 ms |
14288 KB |
Output is correct |
9 |
Correct |
8 ms |
14348 KB |
Output is correct |
10 |
Correct |
8 ms |
14288 KB |
Output is correct |
11 |
Correct |
8 ms |
14288 KB |
Output is correct |
12 |
Correct |
7 ms |
14288 KB |
Output is correct |
13 |
Incorrect |
8 ms |
14288 KB |
Wrong Answer[1] |
14 |
Halted |
0 ms |
0 KB |
- |