#include "game.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 12;
int n, k, s[N], t[N];
vector<int> g[N], gr[N];
void init(int nn, int kk) {
n = nn;
k = kk;
for(int i = k; i < n; i++) {
s[i] = -1, t[i] = k;
}
for(int i = 0; i < k; ++i) {
s[i] = t[i] = i;
}
}
int vis[N], timer;
void dfs(int v, int val) {
vis[v] = timer;
s[v] = max(s[v], val);
for(int to:g[v]) if(vis[to] != timer && s[to] < val) {
dfs(to, val);
}
}
void dfs1(int v, int val) {
t[v] = min(t[v], val);
for(int to:g[v]) if(vis[to] != timer && t[to] > val) {
dfs1(to, val);
}
}
bool cyc = 0;
int add_teleporter(int u, int v) {
if(max(u, v) < k) {
if(u >= v) cyc = 1;
}
if(cyc) return 1;
g[u].push_back(v);
gr[v].push_back(u);
timer++;
dfs(v, s[u]);
timer++;
dfs1(u, t[v]);
vis[v] = timer;
for(int i = k; i < n; i++) {
if(s[i] >= t[i]) {
cyc = 1;
return 1;
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
14416 KB |
Output is correct |
2 |
Correct |
10 ms |
14460 KB |
Output is correct |
3 |
Correct |
14 ms |
14416 KB |
Output is correct |
4 |
Correct |
10 ms |
14416 KB |
Output is correct |
5 |
Correct |
10 ms |
14416 KB |
Output is correct |
6 |
Correct |
10 ms |
14428 KB |
Output is correct |
7 |
Correct |
10 ms |
14416 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
14416 KB |
Output is correct |
2 |
Correct |
10 ms |
14460 KB |
Output is correct |
3 |
Correct |
14 ms |
14416 KB |
Output is correct |
4 |
Correct |
10 ms |
14416 KB |
Output is correct |
5 |
Correct |
10 ms |
14416 KB |
Output is correct |
6 |
Correct |
10 ms |
14428 KB |
Output is correct |
7 |
Correct |
10 ms |
14416 KB |
Output is correct |
8 |
Correct |
11 ms |
14416 KB |
Output is correct |
9 |
Correct |
10 ms |
14416 KB |
Output is correct |
10 |
Correct |
10 ms |
14416 KB |
Output is correct |
11 |
Incorrect |
10 ms |
14416 KB |
Wrong Answer[1] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
14416 KB |
Output is correct |
2 |
Correct |
10 ms |
14460 KB |
Output is correct |
3 |
Correct |
14 ms |
14416 KB |
Output is correct |
4 |
Correct |
10 ms |
14416 KB |
Output is correct |
5 |
Correct |
10 ms |
14416 KB |
Output is correct |
6 |
Correct |
10 ms |
14428 KB |
Output is correct |
7 |
Correct |
10 ms |
14416 KB |
Output is correct |
8 |
Correct |
11 ms |
14416 KB |
Output is correct |
9 |
Correct |
10 ms |
14416 KB |
Output is correct |
10 |
Correct |
10 ms |
14416 KB |
Output is correct |
11 |
Incorrect |
10 ms |
14416 KB |
Wrong Answer[1] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
14416 KB |
Output is correct |
2 |
Correct |
10 ms |
14460 KB |
Output is correct |
3 |
Correct |
14 ms |
14416 KB |
Output is correct |
4 |
Correct |
10 ms |
14416 KB |
Output is correct |
5 |
Correct |
10 ms |
14416 KB |
Output is correct |
6 |
Correct |
10 ms |
14428 KB |
Output is correct |
7 |
Correct |
10 ms |
14416 KB |
Output is correct |
8 |
Correct |
11 ms |
14416 KB |
Output is correct |
9 |
Correct |
10 ms |
14416 KB |
Output is correct |
10 |
Correct |
10 ms |
14416 KB |
Output is correct |
11 |
Incorrect |
10 ms |
14416 KB |
Wrong Answer[1] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
14416 KB |
Output is correct |
2 |
Correct |
10 ms |
14460 KB |
Output is correct |
3 |
Correct |
14 ms |
14416 KB |
Output is correct |
4 |
Correct |
10 ms |
14416 KB |
Output is correct |
5 |
Correct |
10 ms |
14416 KB |
Output is correct |
6 |
Correct |
10 ms |
14428 KB |
Output is correct |
7 |
Correct |
10 ms |
14416 KB |
Output is correct |
8 |
Correct |
11 ms |
14416 KB |
Output is correct |
9 |
Correct |
10 ms |
14416 KB |
Output is correct |
10 |
Correct |
10 ms |
14416 KB |
Output is correct |
11 |
Incorrect |
10 ms |
14416 KB |
Wrong Answer[1] |
12 |
Halted |
0 ms |
0 KB |
- |