# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
987655 |
2024-05-23T09:45:10 Z |
CSQ31 |
게임 (APIO22_game) |
C++17 |
|
2564 ms |
88240 KB |
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) (int)(a.size())
int n,k;
const int MAXN = 3e5+1;
vector<int>g[MAXN],gr[MAXN];
int L[MAXN],R[MAXN];
void init(int N, int K)
{
n=N;
k=K;
for(int i=0;i<k;i++)L[i] = R[i] = i;
for(int i=k;i<n;i++){
L[i] = -1;
R[i] = k;
}
}
bool add(int u,int v){
//cout<<"edge "<<u<<" "<<v<<'\n';
//cout<<L[u]<<" "<<R[u]<<" "<<L[v]<<" "<<R[v]<<'\n';
if(L[u] >= R[v])return 1; //always cycle
if(L[v] > R[u])return 0; //never forms cycle
if(L[v] == L[u] && R[v] == R[u])return 0;//also never forms cycle
int mu = (L[u] + R[u] + 1)/2;
int mv = (L[v] + R[v] + 1)/2;
//[L[u],mu-1] [mu,R[u]]
if(R[v] < mu){
R[u] = mu-1;
for(int x:g[u]){
if(add(u,x))return 1;
}
for(int x:gr[u]){
if(add(x,u))return 1;
}
}
else if(L[u] >= mv){
L[v] = mv;
for(int x:g[v]){
if(add(v,x))return 1;
}
for(int x:gr[v]){
if(add(x,v))return 1;
}
}
return 0;
}
int add_teleporter(int u, int v) {
if(u<k && v<k){
if(u>=v)return 1;
return 0;
}
g[u].pb(v);
gr[v].pb(u);
return add(u,v);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
14424 KB |
Output is correct |
2 |
Correct |
10 ms |
14424 KB |
Output is correct |
3 |
Correct |
12 ms |
14424 KB |
Output is correct |
4 |
Correct |
11 ms |
14436 KB |
Output is correct |
5 |
Correct |
11 ms |
14428 KB |
Output is correct |
6 |
Correct |
10 ms |
14424 KB |
Output is correct |
7 |
Correct |
10 ms |
14428 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
14424 KB |
Output is correct |
2 |
Correct |
10 ms |
14424 KB |
Output is correct |
3 |
Correct |
12 ms |
14424 KB |
Output is correct |
4 |
Correct |
11 ms |
14436 KB |
Output is correct |
5 |
Correct |
11 ms |
14428 KB |
Output is correct |
6 |
Correct |
10 ms |
14424 KB |
Output is correct |
7 |
Correct |
10 ms |
14428 KB |
Output is correct |
8 |
Correct |
11 ms |
14424 KB |
Output is correct |
9 |
Correct |
11 ms |
14432 KB |
Output is correct |
10 |
Correct |
9 ms |
14432 KB |
Output is correct |
11 |
Correct |
12 ms |
14424 KB |
Output is correct |
12 |
Correct |
11 ms |
14428 KB |
Output is correct |
13 |
Correct |
9 ms |
14424 KB |
Output is correct |
14 |
Correct |
9 ms |
14424 KB |
Output is correct |
15 |
Correct |
8 ms |
14424 KB |
Output is correct |
16 |
Correct |
8 ms |
14424 KB |
Output is correct |
17 |
Correct |
9 ms |
14424 KB |
Output is correct |
18 |
Correct |
10 ms |
14424 KB |
Output is correct |
19 |
Correct |
9 ms |
14424 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
14424 KB |
Output is correct |
2 |
Correct |
10 ms |
14424 KB |
Output is correct |
3 |
Correct |
12 ms |
14424 KB |
Output is correct |
4 |
Correct |
11 ms |
14436 KB |
Output is correct |
5 |
Correct |
11 ms |
14428 KB |
Output is correct |
6 |
Correct |
10 ms |
14424 KB |
Output is correct |
7 |
Correct |
10 ms |
14428 KB |
Output is correct |
8 |
Correct |
11 ms |
14424 KB |
Output is correct |
9 |
Correct |
11 ms |
14432 KB |
Output is correct |
10 |
Correct |
9 ms |
14432 KB |
Output is correct |
11 |
Correct |
12 ms |
14424 KB |
Output is correct |
12 |
Correct |
11 ms |
14428 KB |
Output is correct |
13 |
Correct |
9 ms |
14424 KB |
Output is correct |
14 |
Correct |
9 ms |
14424 KB |
Output is correct |
15 |
Correct |
8 ms |
14424 KB |
Output is correct |
16 |
Correct |
8 ms |
14424 KB |
Output is correct |
17 |
Correct |
9 ms |
14424 KB |
Output is correct |
18 |
Correct |
10 ms |
14424 KB |
Output is correct |
19 |
Correct |
9 ms |
14424 KB |
Output is correct |
20 |
Correct |
10 ms |
14424 KB |
Output is correct |
21 |
Correct |
9 ms |
14424 KB |
Output is correct |
22 |
Correct |
9 ms |
14424 KB |
Output is correct |
23 |
Correct |
10 ms |
14424 KB |
Output is correct |
24 |
Correct |
10 ms |
14792 KB |
Output is correct |
25 |
Correct |
10 ms |
14424 KB |
Output is correct |
26 |
Correct |
14 ms |
14864 KB |
Output is correct |
27 |
Correct |
11 ms |
14424 KB |
Output is correct |
28 |
Correct |
10 ms |
14424 KB |
Output is correct |
29 |
Correct |
11 ms |
14424 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
14424 KB |
Output is correct |
2 |
Correct |
10 ms |
14424 KB |
Output is correct |
3 |
Correct |
12 ms |
14424 KB |
Output is correct |
4 |
Correct |
11 ms |
14436 KB |
Output is correct |
5 |
Correct |
11 ms |
14428 KB |
Output is correct |
6 |
Correct |
10 ms |
14424 KB |
Output is correct |
7 |
Correct |
10 ms |
14428 KB |
Output is correct |
8 |
Correct |
11 ms |
14424 KB |
Output is correct |
9 |
Correct |
11 ms |
14432 KB |
Output is correct |
10 |
Correct |
9 ms |
14432 KB |
Output is correct |
11 |
Correct |
12 ms |
14424 KB |
Output is correct |
12 |
Correct |
11 ms |
14428 KB |
Output is correct |
13 |
Correct |
9 ms |
14424 KB |
Output is correct |
14 |
Correct |
9 ms |
14424 KB |
Output is correct |
15 |
Correct |
8 ms |
14424 KB |
Output is correct |
16 |
Correct |
8 ms |
14424 KB |
Output is correct |
17 |
Correct |
9 ms |
14424 KB |
Output is correct |
18 |
Correct |
10 ms |
14424 KB |
Output is correct |
19 |
Correct |
9 ms |
14424 KB |
Output is correct |
20 |
Correct |
10 ms |
14424 KB |
Output is correct |
21 |
Correct |
9 ms |
14424 KB |
Output is correct |
22 |
Correct |
9 ms |
14424 KB |
Output is correct |
23 |
Correct |
10 ms |
14424 KB |
Output is correct |
24 |
Correct |
10 ms |
14792 KB |
Output is correct |
25 |
Correct |
10 ms |
14424 KB |
Output is correct |
26 |
Correct |
14 ms |
14864 KB |
Output is correct |
27 |
Correct |
11 ms |
14424 KB |
Output is correct |
28 |
Correct |
10 ms |
14424 KB |
Output is correct |
29 |
Correct |
11 ms |
14424 KB |
Output is correct |
30 |
Correct |
21 ms |
15796 KB |
Output is correct |
31 |
Correct |
14 ms |
15192 KB |
Output is correct |
32 |
Correct |
30 ms |
20312 KB |
Output is correct |
33 |
Correct |
28 ms |
16976 KB |
Output is correct |
34 |
Correct |
45 ms |
24900 KB |
Output is correct |
35 |
Correct |
47 ms |
17576 KB |
Output is correct |
36 |
Correct |
41 ms |
16828 KB |
Output is correct |
37 |
Correct |
47 ms |
16988 KB |
Output is correct |
38 |
Correct |
49 ms |
16460 KB |
Output is correct |
39 |
Correct |
47 ms |
16716 KB |
Output is correct |
40 |
Correct |
34 ms |
18256 KB |
Output is correct |
41 |
Correct |
42 ms |
17484 KB |
Output is correct |
42 |
Correct |
38 ms |
18480 KB |
Output is correct |
43 |
Correct |
57 ms |
17868 KB |
Output is correct |
44 |
Correct |
58 ms |
17712 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
14424 KB |
Output is correct |
2 |
Correct |
10 ms |
14424 KB |
Output is correct |
3 |
Correct |
12 ms |
14424 KB |
Output is correct |
4 |
Correct |
11 ms |
14436 KB |
Output is correct |
5 |
Correct |
11 ms |
14428 KB |
Output is correct |
6 |
Correct |
10 ms |
14424 KB |
Output is correct |
7 |
Correct |
10 ms |
14428 KB |
Output is correct |
8 |
Correct |
11 ms |
14424 KB |
Output is correct |
9 |
Correct |
11 ms |
14432 KB |
Output is correct |
10 |
Correct |
9 ms |
14432 KB |
Output is correct |
11 |
Correct |
12 ms |
14424 KB |
Output is correct |
12 |
Correct |
11 ms |
14428 KB |
Output is correct |
13 |
Correct |
9 ms |
14424 KB |
Output is correct |
14 |
Correct |
9 ms |
14424 KB |
Output is correct |
15 |
Correct |
8 ms |
14424 KB |
Output is correct |
16 |
Correct |
8 ms |
14424 KB |
Output is correct |
17 |
Correct |
9 ms |
14424 KB |
Output is correct |
18 |
Correct |
10 ms |
14424 KB |
Output is correct |
19 |
Correct |
9 ms |
14424 KB |
Output is correct |
20 |
Correct |
10 ms |
14424 KB |
Output is correct |
21 |
Correct |
9 ms |
14424 KB |
Output is correct |
22 |
Correct |
9 ms |
14424 KB |
Output is correct |
23 |
Correct |
10 ms |
14424 KB |
Output is correct |
24 |
Correct |
10 ms |
14792 KB |
Output is correct |
25 |
Correct |
10 ms |
14424 KB |
Output is correct |
26 |
Correct |
14 ms |
14864 KB |
Output is correct |
27 |
Correct |
11 ms |
14424 KB |
Output is correct |
28 |
Correct |
10 ms |
14424 KB |
Output is correct |
29 |
Correct |
11 ms |
14424 KB |
Output is correct |
30 |
Correct |
21 ms |
15796 KB |
Output is correct |
31 |
Correct |
14 ms |
15192 KB |
Output is correct |
32 |
Correct |
30 ms |
20312 KB |
Output is correct |
33 |
Correct |
28 ms |
16976 KB |
Output is correct |
34 |
Correct |
45 ms |
24900 KB |
Output is correct |
35 |
Correct |
47 ms |
17576 KB |
Output is correct |
36 |
Correct |
41 ms |
16828 KB |
Output is correct |
37 |
Correct |
47 ms |
16988 KB |
Output is correct |
38 |
Correct |
49 ms |
16460 KB |
Output is correct |
39 |
Correct |
47 ms |
16716 KB |
Output is correct |
40 |
Correct |
34 ms |
18256 KB |
Output is correct |
41 |
Correct |
42 ms |
17484 KB |
Output is correct |
42 |
Correct |
38 ms |
18480 KB |
Output is correct |
43 |
Correct |
57 ms |
17868 KB |
Output is correct |
44 |
Correct |
58 ms |
17712 KB |
Output is correct |
45 |
Correct |
304 ms |
28648 KB |
Output is correct |
46 |
Correct |
16 ms |
17240 KB |
Output is correct |
47 |
Correct |
17 ms |
17496 KB |
Output is correct |
48 |
Correct |
527 ms |
41820 KB |
Output is correct |
49 |
Correct |
342 ms |
36064 KB |
Output is correct |
50 |
Correct |
934 ms |
88240 KB |
Output is correct |
51 |
Correct |
1353 ms |
49312 KB |
Output is correct |
52 |
Correct |
826 ms |
35896 KB |
Output is correct |
53 |
Correct |
1198 ms |
36016 KB |
Output is correct |
54 |
Correct |
1349 ms |
35904 KB |
Output is correct |
55 |
Correct |
1830 ms |
36484 KB |
Output is correct |
56 |
Correct |
2278 ms |
36136 KB |
Output is correct |
57 |
Correct |
657 ms |
30288 KB |
Output is correct |
58 |
Correct |
645 ms |
30280 KB |
Output is correct |
59 |
Correct |
581 ms |
30428 KB |
Output is correct |
60 |
Correct |
867 ms |
29820 KB |
Output is correct |
61 |
Correct |
1188 ms |
29840 KB |
Output is correct |
62 |
Correct |
524 ms |
37656 KB |
Output is correct |
63 |
Correct |
599 ms |
34540 KB |
Output is correct |
64 |
Correct |
1882 ms |
56236 KB |
Output is correct |
65 |
Correct |
623 ms |
36988 KB |
Output is correct |
66 |
Correct |
493 ms |
31432 KB |
Output is correct |
67 |
Correct |
1110 ms |
53396 KB |
Output is correct |
68 |
Correct |
230 ms |
26736 KB |
Output is correct |
69 |
Correct |
62 ms |
20816 KB |
Output is correct |
70 |
Correct |
1086 ms |
39496 KB |
Output is correct |
71 |
Correct |
378 ms |
28704 KB |
Output is correct |
72 |
Correct |
297 ms |
24732 KB |
Output is correct |
73 |
Correct |
825 ms |
38876 KB |
Output is correct |
74 |
Correct |
2564 ms |
35728 KB |
Output is correct |
75 |
Correct |
1506 ms |
43648 KB |
Output is correct |
76 |
Correct |
1768 ms |
49456 KB |
Output is correct |