#include "game.h"
#include <vector>
#include <cstdio>
#define PB push_back
using namespace std;
const int N = 5e5 + 500;
int n, k, ans;
vector < int > v[N], r[N];
int L[N], R[N];
void init(int _n, int _k) {
n = _n, k = _k;
for(int i = 0;i < n;i++)
L[i] = n, R[i] = -1;
for(int i = 0;i < k;i++)
L[i] = i, R[i] = i;
}
void noviL(int x, int vr){
L[x] = vr;
for(int y : r[x])
if(vr < L[y]) noviL(y, vr);
}
void noviR(int x, int vr){
R[x] = vr;
for(int y : v[x])
if(vr > R[y]) noviR(y, vr);
}
int add_teleporter(int a, int b) {
if(a >= b && a < k) ans = 1;
if(L[b] < L[a]) noviL(a, L[b]);
if(R[a] > R[b]) noviR(b, R[a]);
ans |= L[b] <= R[a];
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
23760 KB |
Output is correct |
2 |
Correct |
13 ms |
23760 KB |
Output is correct |
3 |
Correct |
11 ms |
23760 KB |
Output is correct |
4 |
Correct |
11 ms |
23760 KB |
Output is correct |
5 |
Correct |
11 ms |
23692 KB |
Output is correct |
6 |
Correct |
12 ms |
23728 KB |
Output is correct |
7 |
Correct |
11 ms |
23724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
23760 KB |
Output is correct |
2 |
Correct |
13 ms |
23760 KB |
Output is correct |
3 |
Correct |
11 ms |
23760 KB |
Output is correct |
4 |
Correct |
11 ms |
23760 KB |
Output is correct |
5 |
Correct |
11 ms |
23692 KB |
Output is correct |
6 |
Correct |
12 ms |
23728 KB |
Output is correct |
7 |
Correct |
11 ms |
23724 KB |
Output is correct |
8 |
Correct |
12 ms |
23760 KB |
Output is correct |
9 |
Correct |
11 ms |
23760 KB |
Output is correct |
10 |
Correct |
11 ms |
23760 KB |
Output is correct |
11 |
Incorrect |
10 ms |
23756 KB |
Wrong Answer[1] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
23760 KB |
Output is correct |
2 |
Correct |
13 ms |
23760 KB |
Output is correct |
3 |
Correct |
11 ms |
23760 KB |
Output is correct |
4 |
Correct |
11 ms |
23760 KB |
Output is correct |
5 |
Correct |
11 ms |
23692 KB |
Output is correct |
6 |
Correct |
12 ms |
23728 KB |
Output is correct |
7 |
Correct |
11 ms |
23724 KB |
Output is correct |
8 |
Correct |
12 ms |
23760 KB |
Output is correct |
9 |
Correct |
11 ms |
23760 KB |
Output is correct |
10 |
Correct |
11 ms |
23760 KB |
Output is correct |
11 |
Incorrect |
10 ms |
23756 KB |
Wrong Answer[1] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
23760 KB |
Output is correct |
2 |
Correct |
13 ms |
23760 KB |
Output is correct |
3 |
Correct |
11 ms |
23760 KB |
Output is correct |
4 |
Correct |
11 ms |
23760 KB |
Output is correct |
5 |
Correct |
11 ms |
23692 KB |
Output is correct |
6 |
Correct |
12 ms |
23728 KB |
Output is correct |
7 |
Correct |
11 ms |
23724 KB |
Output is correct |
8 |
Correct |
12 ms |
23760 KB |
Output is correct |
9 |
Correct |
11 ms |
23760 KB |
Output is correct |
10 |
Correct |
11 ms |
23760 KB |
Output is correct |
11 |
Incorrect |
10 ms |
23756 KB |
Wrong Answer[1] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
23760 KB |
Output is correct |
2 |
Correct |
13 ms |
23760 KB |
Output is correct |
3 |
Correct |
11 ms |
23760 KB |
Output is correct |
4 |
Correct |
11 ms |
23760 KB |
Output is correct |
5 |
Correct |
11 ms |
23692 KB |
Output is correct |
6 |
Correct |
12 ms |
23728 KB |
Output is correct |
7 |
Correct |
11 ms |
23724 KB |
Output is correct |
8 |
Correct |
12 ms |
23760 KB |
Output is correct |
9 |
Correct |
11 ms |
23760 KB |
Output is correct |
10 |
Correct |
11 ms |
23760 KB |
Output is correct |
11 |
Incorrect |
10 ms |
23756 KB |
Wrong Answer[1] |
12 |
Halted |
0 ms |
0 KB |
- |