# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
987658 |
2024-05-23T09:47:26 Z |
CSQ31 |
Game (APIO22_game) |
C++17 |
|
2527 ms |
88020 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);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
14424 KB |
Output is correct |
2 |
Correct |
7 ms |
14424 KB |
Output is correct |
3 |
Correct |
8 ms |
14424 KB |
Output is correct |
4 |
Correct |
9 ms |
14424 KB |
Output is correct |
5 |
Correct |
8 ms |
14424 KB |
Output is correct |
6 |
Correct |
7 ms |
14424 KB |
Output is correct |
7 |
Correct |
7 ms |
14424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
14424 KB |
Output is correct |
2 |
Correct |
7 ms |
14424 KB |
Output is correct |
3 |
Correct |
8 ms |
14424 KB |
Output is correct |
4 |
Correct |
9 ms |
14424 KB |
Output is correct |
5 |
Correct |
8 ms |
14424 KB |
Output is correct |
6 |
Correct |
7 ms |
14424 KB |
Output is correct |
7 |
Correct |
7 ms |
14424 KB |
Output is correct |
8 |
Correct |
9 ms |
14424 KB |
Output is correct |
9 |
Correct |
7 ms |
14424 KB |
Output is correct |
10 |
Correct |
10 ms |
14480 KB |
Output is correct |
11 |
Correct |
10 ms |
14428 KB |
Output is correct |
12 |
Correct |
8 ms |
14424 KB |
Output is correct |
13 |
Correct |
9 ms |
14424 KB |
Output is correct |
14 |
Correct |
10 ms |
14436 KB |
Output is correct |
15 |
Correct |
9 ms |
14508 KB |
Output is correct |
16 |
Correct |
10 ms |
14424 KB |
Output is correct |
17 |
Correct |
10 ms |
14424 KB |
Output is correct |
18 |
Correct |
10 ms |
14424 KB |
Output is correct |
19 |
Correct |
10 ms |
14424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
14424 KB |
Output is correct |
2 |
Correct |
7 ms |
14424 KB |
Output is correct |
3 |
Correct |
8 ms |
14424 KB |
Output is correct |
4 |
Correct |
9 ms |
14424 KB |
Output is correct |
5 |
Correct |
8 ms |
14424 KB |
Output is correct |
6 |
Correct |
7 ms |
14424 KB |
Output is correct |
7 |
Correct |
7 ms |
14424 KB |
Output is correct |
8 |
Correct |
9 ms |
14424 KB |
Output is correct |
9 |
Correct |
7 ms |
14424 KB |
Output is correct |
10 |
Correct |
10 ms |
14480 KB |
Output is correct |
11 |
Correct |
10 ms |
14428 KB |
Output is correct |
12 |
Correct |
8 ms |
14424 KB |
Output is correct |
13 |
Correct |
9 ms |
14424 KB |
Output is correct |
14 |
Correct |
10 ms |
14436 KB |
Output is correct |
15 |
Correct |
9 ms |
14508 KB |
Output is correct |
16 |
Correct |
10 ms |
14424 KB |
Output is correct |
17 |
Correct |
10 ms |
14424 KB |
Output is correct |
18 |
Correct |
10 ms |
14424 KB |
Output is correct |
19 |
Correct |
10 ms |
14424 KB |
Output is correct |
20 |
Correct |
8 ms |
14424 KB |
Output is correct |
21 |
Correct |
9 ms |
14424 KB |
Output is correct |
22 |
Correct |
8 ms |
14424 KB |
Output is correct |
23 |
Correct |
11 ms |
14592 KB |
Output is correct |
24 |
Correct |
9 ms |
14408 KB |
Output is correct |
25 |
Correct |
10 ms |
14900 KB |
Output is correct |
26 |
Correct |
10 ms |
14424 KB |
Output is correct |
27 |
Correct |
10 ms |
14424 KB |
Output is correct |
28 |
Correct |
10 ms |
14680 KB |
Output is correct |
29 |
Correct |
8 ms |
14424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
14424 KB |
Output is correct |
2 |
Correct |
7 ms |
14424 KB |
Output is correct |
3 |
Correct |
8 ms |
14424 KB |
Output is correct |
4 |
Correct |
9 ms |
14424 KB |
Output is correct |
5 |
Correct |
8 ms |
14424 KB |
Output is correct |
6 |
Correct |
7 ms |
14424 KB |
Output is correct |
7 |
Correct |
7 ms |
14424 KB |
Output is correct |
8 |
Correct |
9 ms |
14424 KB |
Output is correct |
9 |
Correct |
7 ms |
14424 KB |
Output is correct |
10 |
Correct |
10 ms |
14480 KB |
Output is correct |
11 |
Correct |
10 ms |
14428 KB |
Output is correct |
12 |
Correct |
8 ms |
14424 KB |
Output is correct |
13 |
Correct |
9 ms |
14424 KB |
Output is correct |
14 |
Correct |
10 ms |
14436 KB |
Output is correct |
15 |
Correct |
9 ms |
14508 KB |
Output is correct |
16 |
Correct |
10 ms |
14424 KB |
Output is correct |
17 |
Correct |
10 ms |
14424 KB |
Output is correct |
18 |
Correct |
10 ms |
14424 KB |
Output is correct |
19 |
Correct |
10 ms |
14424 KB |
Output is correct |
20 |
Correct |
8 ms |
14424 KB |
Output is correct |
21 |
Correct |
9 ms |
14424 KB |
Output is correct |
22 |
Correct |
8 ms |
14424 KB |
Output is correct |
23 |
Correct |
11 ms |
14592 KB |
Output is correct |
24 |
Correct |
9 ms |
14408 KB |
Output is correct |
25 |
Correct |
10 ms |
14900 KB |
Output is correct |
26 |
Correct |
10 ms |
14424 KB |
Output is correct |
27 |
Correct |
10 ms |
14424 KB |
Output is correct |
28 |
Correct |
10 ms |
14680 KB |
Output is correct |
29 |
Correct |
8 ms |
14424 KB |
Output is correct |
30 |
Correct |
25 ms |
16272 KB |
Output is correct |
31 |
Correct |
15 ms |
15260 KB |
Output is correct |
32 |
Correct |
31 ms |
19972 KB |
Output is correct |
33 |
Correct |
29 ms |
16448 KB |
Output is correct |
34 |
Correct |
42 ms |
25168 KB |
Output is correct |
35 |
Correct |
50 ms |
18348 KB |
Output is correct |
36 |
Correct |
41 ms |
16652 KB |
Output is correct |
37 |
Correct |
49 ms |
16768 KB |
Output is correct |
38 |
Correct |
31 ms |
16592 KB |
Output is correct |
39 |
Correct |
55 ms |
16976 KB |
Output is correct |
40 |
Correct |
41 ms |
18144 KB |
Output is correct |
41 |
Correct |
54 ms |
17496 KB |
Output is correct |
42 |
Correct |
33 ms |
17996 KB |
Output is correct |
43 |
Correct |
44 ms |
18000 KB |
Output is correct |
44 |
Correct |
51 ms |
17712 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
14424 KB |
Output is correct |
2 |
Correct |
7 ms |
14424 KB |
Output is correct |
3 |
Correct |
8 ms |
14424 KB |
Output is correct |
4 |
Correct |
9 ms |
14424 KB |
Output is correct |
5 |
Correct |
8 ms |
14424 KB |
Output is correct |
6 |
Correct |
7 ms |
14424 KB |
Output is correct |
7 |
Correct |
7 ms |
14424 KB |
Output is correct |
8 |
Correct |
9 ms |
14424 KB |
Output is correct |
9 |
Correct |
7 ms |
14424 KB |
Output is correct |
10 |
Correct |
10 ms |
14480 KB |
Output is correct |
11 |
Correct |
10 ms |
14428 KB |
Output is correct |
12 |
Correct |
8 ms |
14424 KB |
Output is correct |
13 |
Correct |
9 ms |
14424 KB |
Output is correct |
14 |
Correct |
10 ms |
14436 KB |
Output is correct |
15 |
Correct |
9 ms |
14508 KB |
Output is correct |
16 |
Correct |
10 ms |
14424 KB |
Output is correct |
17 |
Correct |
10 ms |
14424 KB |
Output is correct |
18 |
Correct |
10 ms |
14424 KB |
Output is correct |
19 |
Correct |
10 ms |
14424 KB |
Output is correct |
20 |
Correct |
8 ms |
14424 KB |
Output is correct |
21 |
Correct |
9 ms |
14424 KB |
Output is correct |
22 |
Correct |
8 ms |
14424 KB |
Output is correct |
23 |
Correct |
11 ms |
14592 KB |
Output is correct |
24 |
Correct |
9 ms |
14408 KB |
Output is correct |
25 |
Correct |
10 ms |
14900 KB |
Output is correct |
26 |
Correct |
10 ms |
14424 KB |
Output is correct |
27 |
Correct |
10 ms |
14424 KB |
Output is correct |
28 |
Correct |
10 ms |
14680 KB |
Output is correct |
29 |
Correct |
8 ms |
14424 KB |
Output is correct |
30 |
Correct |
25 ms |
16272 KB |
Output is correct |
31 |
Correct |
15 ms |
15260 KB |
Output is correct |
32 |
Correct |
31 ms |
19972 KB |
Output is correct |
33 |
Correct |
29 ms |
16448 KB |
Output is correct |
34 |
Correct |
42 ms |
25168 KB |
Output is correct |
35 |
Correct |
50 ms |
18348 KB |
Output is correct |
36 |
Correct |
41 ms |
16652 KB |
Output is correct |
37 |
Correct |
49 ms |
16768 KB |
Output is correct |
38 |
Correct |
31 ms |
16592 KB |
Output is correct |
39 |
Correct |
55 ms |
16976 KB |
Output is correct |
40 |
Correct |
41 ms |
18144 KB |
Output is correct |
41 |
Correct |
54 ms |
17496 KB |
Output is correct |
42 |
Correct |
33 ms |
17996 KB |
Output is correct |
43 |
Correct |
44 ms |
18000 KB |
Output is correct |
44 |
Correct |
51 ms |
17712 KB |
Output is correct |
45 |
Correct |
290 ms |
28136 KB |
Output is correct |
46 |
Correct |
16 ms |
17240 KB |
Output is correct |
47 |
Correct |
13 ms |
17240 KB |
Output is correct |
48 |
Correct |
553 ms |
41868 KB |
Output is correct |
49 |
Correct |
354 ms |
36492 KB |
Output is correct |
50 |
Correct |
829 ms |
88020 KB |
Output is correct |
51 |
Correct |
1491 ms |
49564 KB |
Output is correct |
52 |
Correct |
807 ms |
35664 KB |
Output is correct |
53 |
Correct |
1133 ms |
36020 KB |
Output is correct |
54 |
Correct |
1245 ms |
35552 KB |
Output is correct |
55 |
Correct |
1923 ms |
36480 KB |
Output is correct |
56 |
Correct |
2316 ms |
36160 KB |
Output is correct |
57 |
Correct |
630 ms |
29968 KB |
Output is correct |
58 |
Correct |
638 ms |
30188 KB |
Output is correct |
59 |
Correct |
641 ms |
30396 KB |
Output is correct |
60 |
Correct |
779 ms |
29736 KB |
Output is correct |
61 |
Correct |
962 ms |
30308 KB |
Output is correct |
62 |
Correct |
619 ms |
37432 KB |
Output is correct |
63 |
Correct |
477 ms |
34064 KB |
Output is correct |
64 |
Correct |
1822 ms |
56232 KB |
Output is correct |
65 |
Correct |
662 ms |
36988 KB |
Output is correct |
66 |
Correct |
465 ms |
31412 KB |
Output is correct |
67 |
Correct |
1004 ms |
53484 KB |
Output is correct |
68 |
Correct |
234 ms |
27056 KB |
Output is correct |
69 |
Correct |
69 ms |
20624 KB |
Output is correct |
70 |
Correct |
1041 ms |
39300 KB |
Output is correct |
71 |
Correct |
331 ms |
29404 KB |
Output is correct |
72 |
Correct |
223 ms |
25020 KB |
Output is correct |
73 |
Correct |
789 ms |
38272 KB |
Output is correct |
74 |
Correct |
2527 ms |
35476 KB |
Output is correct |
75 |
Correct |
1447 ms |
43852 KB |
Output is correct |
76 |
Correct |
1746 ms |
49660 KB |
Output is correct |