#include "game.h"
#include <bits/stdc++.h>
#define rep(a,b,c) for(int a=b; a<c; a++)
#define repr(a,b,c) for(int a=b-1; a>c-1; a--)
#define repa(a,b) for(auto a:b)
#define fi first
#define se second
#define pii pair<int, int>
#define ll long long
#define pb push_back
using namespace std;
int N, K;
const int lim=5e5+5;
vector<int> adj[lim];
bool ans=false, vis[lim];
void init(int n, int k) {
N=n; K=k;
}
void dfs(int u, int r){
vis[u]=true;
repa(v,adj[u]){
if(!vis[v]) dfs(v,r);
if(v<=r || ans){
ans=true;
return;
}
}
}
int add_teleporter(int u, int v) {
adj[u].pb(v);
if(ans) return 1;
fill(vis,vis+N,0);
repr(i,K,0) dfs(i,i);
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
12376 KB |
Output is correct |
2 |
Correct |
3 ms |
12376 KB |
Output is correct |
3 |
Correct |
3 ms |
12376 KB |
Output is correct |
4 |
Correct |
3 ms |
12376 KB |
Output is correct |
5 |
Correct |
3 ms |
12376 KB |
Output is correct |
6 |
Correct |
3 ms |
12376 KB |
Output is correct |
7 |
Correct |
4 ms |
12376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
12376 KB |
Output is correct |
2 |
Correct |
3 ms |
12376 KB |
Output is correct |
3 |
Correct |
3 ms |
12376 KB |
Output is correct |
4 |
Correct |
3 ms |
12376 KB |
Output is correct |
5 |
Correct |
3 ms |
12376 KB |
Output is correct |
6 |
Correct |
3 ms |
12376 KB |
Output is correct |
7 |
Correct |
4 ms |
12376 KB |
Output is correct |
8 |
Correct |
5 ms |
12376 KB |
Output is correct |
9 |
Correct |
4 ms |
12376 KB |
Output is correct |
10 |
Correct |
5 ms |
12628 KB |
Output is correct |
11 |
Correct |
6 ms |
12376 KB |
Output is correct |
12 |
Correct |
4 ms |
12376 KB |
Output is correct |
13 |
Correct |
6 ms |
12120 KB |
Output is correct |
14 |
Correct |
3 ms |
12376 KB |
Output is correct |
15 |
Correct |
3 ms |
12376 KB |
Output is correct |
16 |
Correct |
5 ms |
12376 KB |
Output is correct |
17 |
Correct |
5 ms |
12264 KB |
Output is correct |
18 |
Correct |
6 ms |
12468 KB |
Output is correct |
19 |
Correct |
3 ms |
12376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
12376 KB |
Output is correct |
2 |
Correct |
3 ms |
12376 KB |
Output is correct |
3 |
Correct |
3 ms |
12376 KB |
Output is correct |
4 |
Correct |
3 ms |
12376 KB |
Output is correct |
5 |
Correct |
3 ms |
12376 KB |
Output is correct |
6 |
Correct |
3 ms |
12376 KB |
Output is correct |
7 |
Correct |
4 ms |
12376 KB |
Output is correct |
8 |
Correct |
5 ms |
12376 KB |
Output is correct |
9 |
Correct |
4 ms |
12376 KB |
Output is correct |
10 |
Correct |
5 ms |
12628 KB |
Output is correct |
11 |
Correct |
6 ms |
12376 KB |
Output is correct |
12 |
Correct |
4 ms |
12376 KB |
Output is correct |
13 |
Correct |
6 ms |
12120 KB |
Output is correct |
14 |
Correct |
3 ms |
12376 KB |
Output is correct |
15 |
Correct |
3 ms |
12376 KB |
Output is correct |
16 |
Correct |
5 ms |
12376 KB |
Output is correct |
17 |
Correct |
5 ms |
12264 KB |
Output is correct |
18 |
Correct |
6 ms |
12468 KB |
Output is correct |
19 |
Correct |
3 ms |
12376 KB |
Output is correct |
20 |
Correct |
5 ms |
12376 KB |
Output is correct |
21 |
Correct |
4 ms |
12376 KB |
Output is correct |
22 |
Correct |
5 ms |
12376 KB |
Output is correct |
23 |
Correct |
4 ms |
12376 KB |
Output is correct |
24 |
Correct |
7 ms |
12376 KB |
Output is correct |
25 |
Correct |
20 ms |
12288 KB |
Output is correct |
26 |
Correct |
28 ms |
12376 KB |
Output is correct |
27 |
Correct |
26 ms |
12632 KB |
Output is correct |
28 |
Correct |
11 ms |
12632 KB |
Output is correct |
29 |
Correct |
20 ms |
12452 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
12376 KB |
Output is correct |
2 |
Correct |
3 ms |
12376 KB |
Output is correct |
3 |
Correct |
3 ms |
12376 KB |
Output is correct |
4 |
Correct |
3 ms |
12376 KB |
Output is correct |
5 |
Correct |
3 ms |
12376 KB |
Output is correct |
6 |
Correct |
3 ms |
12376 KB |
Output is correct |
7 |
Correct |
4 ms |
12376 KB |
Output is correct |
8 |
Correct |
5 ms |
12376 KB |
Output is correct |
9 |
Correct |
4 ms |
12376 KB |
Output is correct |
10 |
Correct |
5 ms |
12628 KB |
Output is correct |
11 |
Correct |
6 ms |
12376 KB |
Output is correct |
12 |
Correct |
4 ms |
12376 KB |
Output is correct |
13 |
Correct |
6 ms |
12120 KB |
Output is correct |
14 |
Correct |
3 ms |
12376 KB |
Output is correct |
15 |
Correct |
3 ms |
12376 KB |
Output is correct |
16 |
Correct |
5 ms |
12376 KB |
Output is correct |
17 |
Correct |
5 ms |
12264 KB |
Output is correct |
18 |
Correct |
6 ms |
12468 KB |
Output is correct |
19 |
Correct |
3 ms |
12376 KB |
Output is correct |
20 |
Correct |
5 ms |
12376 KB |
Output is correct |
21 |
Correct |
4 ms |
12376 KB |
Output is correct |
22 |
Correct |
5 ms |
12376 KB |
Output is correct |
23 |
Correct |
4 ms |
12376 KB |
Output is correct |
24 |
Correct |
7 ms |
12376 KB |
Output is correct |
25 |
Correct |
20 ms |
12288 KB |
Output is correct |
26 |
Correct |
28 ms |
12376 KB |
Output is correct |
27 |
Correct |
26 ms |
12632 KB |
Output is correct |
28 |
Correct |
11 ms |
12632 KB |
Output is correct |
29 |
Correct |
20 ms |
12452 KB |
Output is correct |
30 |
Correct |
88 ms |
13344 KB |
Output is correct |
31 |
Correct |
38 ms |
12348 KB |
Output is correct |
32 |
Correct |
44 ms |
14292 KB |
Output is correct |
33 |
Correct |
32 ms |
13636 KB |
Output is correct |
34 |
Correct |
887 ms |
15096 KB |
Output is correct |
35 |
Execution timed out |
4100 ms |
13812 KB |
Time limit exceeded |
36 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
12376 KB |
Output is correct |
2 |
Correct |
3 ms |
12376 KB |
Output is correct |
3 |
Correct |
3 ms |
12376 KB |
Output is correct |
4 |
Correct |
3 ms |
12376 KB |
Output is correct |
5 |
Correct |
3 ms |
12376 KB |
Output is correct |
6 |
Correct |
3 ms |
12376 KB |
Output is correct |
7 |
Correct |
4 ms |
12376 KB |
Output is correct |
8 |
Correct |
5 ms |
12376 KB |
Output is correct |
9 |
Correct |
4 ms |
12376 KB |
Output is correct |
10 |
Correct |
5 ms |
12628 KB |
Output is correct |
11 |
Correct |
6 ms |
12376 KB |
Output is correct |
12 |
Correct |
4 ms |
12376 KB |
Output is correct |
13 |
Correct |
6 ms |
12120 KB |
Output is correct |
14 |
Correct |
3 ms |
12376 KB |
Output is correct |
15 |
Correct |
3 ms |
12376 KB |
Output is correct |
16 |
Correct |
5 ms |
12376 KB |
Output is correct |
17 |
Correct |
5 ms |
12264 KB |
Output is correct |
18 |
Correct |
6 ms |
12468 KB |
Output is correct |
19 |
Correct |
3 ms |
12376 KB |
Output is correct |
20 |
Correct |
5 ms |
12376 KB |
Output is correct |
21 |
Correct |
4 ms |
12376 KB |
Output is correct |
22 |
Correct |
5 ms |
12376 KB |
Output is correct |
23 |
Correct |
4 ms |
12376 KB |
Output is correct |
24 |
Correct |
7 ms |
12376 KB |
Output is correct |
25 |
Correct |
20 ms |
12288 KB |
Output is correct |
26 |
Correct |
28 ms |
12376 KB |
Output is correct |
27 |
Correct |
26 ms |
12632 KB |
Output is correct |
28 |
Correct |
11 ms |
12632 KB |
Output is correct |
29 |
Correct |
20 ms |
12452 KB |
Output is correct |
30 |
Correct |
88 ms |
13344 KB |
Output is correct |
31 |
Correct |
38 ms |
12348 KB |
Output is correct |
32 |
Correct |
44 ms |
14292 KB |
Output is correct |
33 |
Correct |
32 ms |
13636 KB |
Output is correct |
34 |
Correct |
887 ms |
15096 KB |
Output is correct |
35 |
Execution timed out |
4100 ms |
13812 KB |
Time limit exceeded |
36 |
Halted |
0 ms |
0 KB |
- |