#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;
const int N = 300000;
int K;
vector<int>adj[2][N];
int mx[2][N];
void init(int n, int k) {
K = k;
for (int i = 0; i < n; i++)
mx[0][i] = -k;
for (int i = 0; i < k; i++)
mx[0][i] = -(i + 1);
for (int i = 0; i < k; i++)
mx[1][i] = i;
for (int i = k; i < n; i++)
mx[1][i] = -1;
}
int add_teleporter(int u, int v) {
int x = min(v, -mx[0][v]);
int y = mx[1][u];
if (y >= x)
return 1;
int V[2] = { -x, y};
for (int t : {1, 0})
{
function<void(int)>dfs = [&](int i) {
mx[t][i] = V[t];
for (int j : adj[t][i])
if (V[t] > mx[t][j])
dfs(j);
};
if (V[t] > mx[t][v])
dfs(v);
swap(u, v);
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
14288 KB |
Output is correct |
2 |
Correct |
10 ms |
14336 KB |
Output is correct |
3 |
Correct |
9 ms |
14288 KB |
Output is correct |
4 |
Correct |
11 ms |
14288 KB |
Output is correct |
5 |
Correct |
12 ms |
14288 KB |
Output is correct |
6 |
Correct |
9 ms |
14344 KB |
Output is correct |
7 |
Correct |
12 ms |
14312 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
14288 KB |
Output is correct |
2 |
Correct |
10 ms |
14336 KB |
Output is correct |
3 |
Correct |
9 ms |
14288 KB |
Output is correct |
4 |
Correct |
11 ms |
14288 KB |
Output is correct |
5 |
Correct |
12 ms |
14288 KB |
Output is correct |
6 |
Correct |
9 ms |
14344 KB |
Output is correct |
7 |
Correct |
12 ms |
14312 KB |
Output is correct |
8 |
Correct |
10 ms |
14288 KB |
Output is correct |
9 |
Correct |
9 ms |
14288 KB |
Output is correct |
10 |
Correct |
9 ms |
14336 KB |
Output is correct |
11 |
Incorrect |
9 ms |
14288 KB |
Wrong Answer[1] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
14288 KB |
Output is correct |
2 |
Correct |
10 ms |
14336 KB |
Output is correct |
3 |
Correct |
9 ms |
14288 KB |
Output is correct |
4 |
Correct |
11 ms |
14288 KB |
Output is correct |
5 |
Correct |
12 ms |
14288 KB |
Output is correct |
6 |
Correct |
9 ms |
14344 KB |
Output is correct |
7 |
Correct |
12 ms |
14312 KB |
Output is correct |
8 |
Correct |
10 ms |
14288 KB |
Output is correct |
9 |
Correct |
9 ms |
14288 KB |
Output is correct |
10 |
Correct |
9 ms |
14336 KB |
Output is correct |
11 |
Incorrect |
9 ms |
14288 KB |
Wrong Answer[1] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
14288 KB |
Output is correct |
2 |
Correct |
10 ms |
14336 KB |
Output is correct |
3 |
Correct |
9 ms |
14288 KB |
Output is correct |
4 |
Correct |
11 ms |
14288 KB |
Output is correct |
5 |
Correct |
12 ms |
14288 KB |
Output is correct |
6 |
Correct |
9 ms |
14344 KB |
Output is correct |
7 |
Correct |
12 ms |
14312 KB |
Output is correct |
8 |
Correct |
10 ms |
14288 KB |
Output is correct |
9 |
Correct |
9 ms |
14288 KB |
Output is correct |
10 |
Correct |
9 ms |
14336 KB |
Output is correct |
11 |
Incorrect |
9 ms |
14288 KB |
Wrong Answer[1] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
14288 KB |
Output is correct |
2 |
Correct |
10 ms |
14336 KB |
Output is correct |
3 |
Correct |
9 ms |
14288 KB |
Output is correct |
4 |
Correct |
11 ms |
14288 KB |
Output is correct |
5 |
Correct |
12 ms |
14288 KB |
Output is correct |
6 |
Correct |
9 ms |
14344 KB |
Output is correct |
7 |
Correct |
12 ms |
14312 KB |
Output is correct |
8 |
Correct |
10 ms |
14288 KB |
Output is correct |
9 |
Correct |
9 ms |
14288 KB |
Output is correct |
10 |
Correct |
9 ms |
14336 KB |
Output is correct |
11 |
Incorrect |
9 ms |
14288 KB |
Wrong Answer[1] |
12 |
Halted |
0 ms |
0 KB |
- |