# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1103918 |
2024-10-22T08:50:05 Z |
epicci23 |
Game (APIO22_game) |
C++17 |
|
778 ms |
36692 KB |
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include "game.h"
#define SIZE 300005
using namespace std;
vector <int> vec[SIZE];
vector <int> rvec[SIZE];
int left[SIZE],right[SIZE];
queue <int> que;
int mum;
void init(int n, int k)
{
mum=1;
while(mum<k+2) mum<<=1;
for(int i=0;i<k;i++) left[i]=i+1,right[i]=i+2;
for(int i=k;i<n;i++) left[i]=0,right[i]=mum;
for(int i=0;i<n;i++)
{
vec[i].clear();
rvec[i].clear();
}
while(!que.empty()) que.pop();
}
bool check(int u,int v)
{
if(right[v]<=left[u]) return true;
if((left[v]+right[v])/2<=left[u])
{
left[v]=(left[v]+right[v])/2;
que.push(v);
}
if(right[v]<=(left[u]+right[u])/2)
{
right[u]=(left[u]+right[u])/2;
que.push(u);
}
return false;
}
int add_teleporter(int u, int v)
{
vec[u].push_back(v);
rvec[v].push_back(u);
if(check(u,v)) return 1;
while(!que.empty())
{
int x=que.front();que.pop();
if(left[x]+1==right[x]) return 1;
for(int i=0;i<vec[x].size();i++)
{
int to=vec[x][i];
if(check(x,to)) return 1;
}
for(int i=0;i<rvec[x].size();i++)
{
int to=rvec[x][i];
if(check(to,x)) return 1;
}
}
return 0;
}
Compilation message
game.cpp: In function 'int add_teleporter(int, int)':
game.cpp:55:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | for(int i=0;i<vec[x].size();i++)
| ~^~~~~~~~~~~~~~
game.cpp:60:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
60 | for(int i=0;i<rvec[x].size();i++)
| ~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
15696 KB |
Output is correct |
2 |
Correct |
3 ms |
15696 KB |
Output is correct |
3 |
Correct |
4 ms |
15696 KB |
Output is correct |
4 |
Correct |
4 ms |
15696 KB |
Output is correct |
5 |
Correct |
5 ms |
15780 KB |
Output is correct |
6 |
Correct |
4 ms |
15696 KB |
Output is correct |
7 |
Correct |
4 ms |
15696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
15696 KB |
Output is correct |
2 |
Correct |
3 ms |
15696 KB |
Output is correct |
3 |
Correct |
4 ms |
15696 KB |
Output is correct |
4 |
Correct |
4 ms |
15696 KB |
Output is correct |
5 |
Correct |
5 ms |
15780 KB |
Output is correct |
6 |
Correct |
4 ms |
15696 KB |
Output is correct |
7 |
Correct |
4 ms |
15696 KB |
Output is correct |
8 |
Correct |
4 ms |
15696 KB |
Output is correct |
9 |
Correct |
3 ms |
15696 KB |
Output is correct |
10 |
Correct |
4 ms |
15696 KB |
Output is correct |
11 |
Correct |
4 ms |
15696 KB |
Output is correct |
12 |
Correct |
3 ms |
15864 KB |
Output is correct |
13 |
Correct |
3 ms |
15696 KB |
Output is correct |
14 |
Correct |
3 ms |
15696 KB |
Output is correct |
15 |
Correct |
3 ms |
15696 KB |
Output is correct |
16 |
Correct |
3 ms |
15696 KB |
Output is correct |
17 |
Correct |
3 ms |
15696 KB |
Output is correct |
18 |
Correct |
4 ms |
15696 KB |
Output is correct |
19 |
Correct |
3 ms |
15696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
15696 KB |
Output is correct |
2 |
Correct |
3 ms |
15696 KB |
Output is correct |
3 |
Correct |
4 ms |
15696 KB |
Output is correct |
4 |
Correct |
4 ms |
15696 KB |
Output is correct |
5 |
Correct |
5 ms |
15780 KB |
Output is correct |
6 |
Correct |
4 ms |
15696 KB |
Output is correct |
7 |
Correct |
4 ms |
15696 KB |
Output is correct |
8 |
Correct |
4 ms |
15696 KB |
Output is correct |
9 |
Correct |
3 ms |
15696 KB |
Output is correct |
10 |
Correct |
4 ms |
15696 KB |
Output is correct |
11 |
Correct |
4 ms |
15696 KB |
Output is correct |
12 |
Correct |
3 ms |
15864 KB |
Output is correct |
13 |
Correct |
3 ms |
15696 KB |
Output is correct |
14 |
Correct |
3 ms |
15696 KB |
Output is correct |
15 |
Correct |
3 ms |
15696 KB |
Output is correct |
16 |
Correct |
3 ms |
15696 KB |
Output is correct |
17 |
Correct |
3 ms |
15696 KB |
Output is correct |
18 |
Correct |
4 ms |
15696 KB |
Output is correct |
19 |
Correct |
3 ms |
15696 KB |
Output is correct |
20 |
Correct |
4 ms |
15696 KB |
Output is correct |
21 |
Correct |
4 ms |
15696 KB |
Output is correct |
22 |
Correct |
4 ms |
15696 KB |
Output is correct |
23 |
Correct |
4 ms |
15696 KB |
Output is correct |
24 |
Correct |
4 ms |
15696 KB |
Output is correct |
25 |
Correct |
5 ms |
15696 KB |
Output is correct |
26 |
Correct |
5 ms |
15788 KB |
Output is correct |
27 |
Correct |
6 ms |
15696 KB |
Output is correct |
28 |
Correct |
4 ms |
15696 KB |
Output is correct |
29 |
Correct |
6 ms |
15696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
15696 KB |
Output is correct |
2 |
Correct |
3 ms |
15696 KB |
Output is correct |
3 |
Correct |
4 ms |
15696 KB |
Output is correct |
4 |
Correct |
4 ms |
15696 KB |
Output is correct |
5 |
Correct |
5 ms |
15780 KB |
Output is correct |
6 |
Correct |
4 ms |
15696 KB |
Output is correct |
7 |
Correct |
4 ms |
15696 KB |
Output is correct |
8 |
Correct |
4 ms |
15696 KB |
Output is correct |
9 |
Correct |
3 ms |
15696 KB |
Output is correct |
10 |
Correct |
4 ms |
15696 KB |
Output is correct |
11 |
Correct |
4 ms |
15696 KB |
Output is correct |
12 |
Correct |
3 ms |
15864 KB |
Output is correct |
13 |
Correct |
3 ms |
15696 KB |
Output is correct |
14 |
Correct |
3 ms |
15696 KB |
Output is correct |
15 |
Correct |
3 ms |
15696 KB |
Output is correct |
16 |
Correct |
3 ms |
15696 KB |
Output is correct |
17 |
Correct |
3 ms |
15696 KB |
Output is correct |
18 |
Correct |
4 ms |
15696 KB |
Output is correct |
19 |
Correct |
3 ms |
15696 KB |
Output is correct |
20 |
Correct |
4 ms |
15696 KB |
Output is correct |
21 |
Correct |
4 ms |
15696 KB |
Output is correct |
22 |
Correct |
4 ms |
15696 KB |
Output is correct |
23 |
Correct |
4 ms |
15696 KB |
Output is correct |
24 |
Correct |
4 ms |
15696 KB |
Output is correct |
25 |
Correct |
5 ms |
15696 KB |
Output is correct |
26 |
Correct |
5 ms |
15788 KB |
Output is correct |
27 |
Correct |
6 ms |
15696 KB |
Output is correct |
28 |
Correct |
4 ms |
15696 KB |
Output is correct |
29 |
Correct |
6 ms |
15696 KB |
Output is correct |
30 |
Correct |
13 ms |
16912 KB |
Output is correct |
31 |
Correct |
6 ms |
16208 KB |
Output is correct |
32 |
Correct |
21 ms |
18236 KB |
Output is correct |
33 |
Correct |
17 ms |
18000 KB |
Output is correct |
34 |
Correct |
22 ms |
17744 KB |
Output is correct |
35 |
Correct |
25 ms |
17860 KB |
Output is correct |
36 |
Correct |
24 ms |
17736 KB |
Output is correct |
37 |
Correct |
32 ms |
17736 KB |
Output is correct |
38 |
Correct |
20 ms |
17488 KB |
Output is correct |
39 |
Correct |
31 ms |
17676 KB |
Output is correct |
40 |
Correct |
32 ms |
17920 KB |
Output is correct |
41 |
Correct |
31 ms |
17980 KB |
Output is correct |
42 |
Correct |
22 ms |
17488 KB |
Output is correct |
43 |
Correct |
25 ms |
17744 KB |
Output is correct |
44 |
Correct |
28 ms |
17756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
15696 KB |
Output is correct |
2 |
Correct |
3 ms |
15696 KB |
Output is correct |
3 |
Correct |
4 ms |
15696 KB |
Output is correct |
4 |
Correct |
4 ms |
15696 KB |
Output is correct |
5 |
Correct |
5 ms |
15780 KB |
Output is correct |
6 |
Correct |
4 ms |
15696 KB |
Output is correct |
7 |
Correct |
4 ms |
15696 KB |
Output is correct |
8 |
Correct |
4 ms |
15696 KB |
Output is correct |
9 |
Correct |
3 ms |
15696 KB |
Output is correct |
10 |
Correct |
4 ms |
15696 KB |
Output is correct |
11 |
Correct |
4 ms |
15696 KB |
Output is correct |
12 |
Correct |
3 ms |
15864 KB |
Output is correct |
13 |
Correct |
3 ms |
15696 KB |
Output is correct |
14 |
Correct |
3 ms |
15696 KB |
Output is correct |
15 |
Correct |
3 ms |
15696 KB |
Output is correct |
16 |
Correct |
3 ms |
15696 KB |
Output is correct |
17 |
Correct |
3 ms |
15696 KB |
Output is correct |
18 |
Correct |
4 ms |
15696 KB |
Output is correct |
19 |
Correct |
3 ms |
15696 KB |
Output is correct |
20 |
Correct |
4 ms |
15696 KB |
Output is correct |
21 |
Correct |
4 ms |
15696 KB |
Output is correct |
22 |
Correct |
4 ms |
15696 KB |
Output is correct |
23 |
Correct |
4 ms |
15696 KB |
Output is correct |
24 |
Correct |
4 ms |
15696 KB |
Output is correct |
25 |
Correct |
5 ms |
15696 KB |
Output is correct |
26 |
Correct |
5 ms |
15788 KB |
Output is correct |
27 |
Correct |
6 ms |
15696 KB |
Output is correct |
28 |
Correct |
4 ms |
15696 KB |
Output is correct |
29 |
Correct |
6 ms |
15696 KB |
Output is correct |
30 |
Correct |
13 ms |
16912 KB |
Output is correct |
31 |
Correct |
6 ms |
16208 KB |
Output is correct |
32 |
Correct |
21 ms |
18236 KB |
Output is correct |
33 |
Correct |
17 ms |
18000 KB |
Output is correct |
34 |
Correct |
22 ms |
17744 KB |
Output is correct |
35 |
Correct |
25 ms |
17860 KB |
Output is correct |
36 |
Correct |
24 ms |
17736 KB |
Output is correct |
37 |
Correct |
32 ms |
17736 KB |
Output is correct |
38 |
Correct |
20 ms |
17488 KB |
Output is correct |
39 |
Correct |
31 ms |
17676 KB |
Output is correct |
40 |
Correct |
32 ms |
17920 KB |
Output is correct |
41 |
Correct |
31 ms |
17980 KB |
Output is correct |
42 |
Correct |
22 ms |
17488 KB |
Output is correct |
43 |
Correct |
25 ms |
17744 KB |
Output is correct |
44 |
Correct |
28 ms |
17756 KB |
Output is correct |
45 |
Correct |
155 ms |
28040 KB |
Output is correct |
46 |
Correct |
8 ms |
17232 KB |
Output is correct |
47 |
Correct |
7 ms |
17232 KB |
Output is correct |
48 |
Correct |
255 ms |
35544 KB |
Output is correct |
49 |
Correct |
185 ms |
35956 KB |
Output is correct |
50 |
Correct |
302 ms |
31788 KB |
Output is correct |
51 |
Correct |
490 ms |
35076 KB |
Output is correct |
52 |
Correct |
382 ms |
35516 KB |
Output is correct |
53 |
Correct |
475 ms |
35520 KB |
Output is correct |
54 |
Correct |
580 ms |
35384 KB |
Output is correct |
55 |
Correct |
668 ms |
35824 KB |
Output is correct |
56 |
Correct |
685 ms |
35536 KB |
Output is correct |
57 |
Correct |
285 ms |
29468 KB |
Output is correct |
58 |
Correct |
356 ms |
29756 KB |
Output is correct |
59 |
Correct |
316 ms |
29440 KB |
Output is correct |
60 |
Correct |
309 ms |
29680 KB |
Output is correct |
61 |
Correct |
350 ms |
29168 KB |
Output is correct |
62 |
Correct |
220 ms |
30012 KB |
Output is correct |
63 |
Correct |
147 ms |
27048 KB |
Output is correct |
64 |
Correct |
590 ms |
35208 KB |
Output is correct |
65 |
Correct |
287 ms |
31460 KB |
Output is correct |
66 |
Correct |
248 ms |
27712 KB |
Output is correct |
67 |
Correct |
417 ms |
35420 KB |
Output is correct |
68 |
Correct |
139 ms |
26712 KB |
Output is correct |
69 |
Correct |
38 ms |
20204 KB |
Output is correct |
70 |
Correct |
463 ms |
32748 KB |
Output is correct |
71 |
Correct |
218 ms |
28900 KB |
Output is correct |
72 |
Correct |
150 ms |
25308 KB |
Output is correct |
73 |
Correct |
348 ms |
33140 KB |
Output is correct |
74 |
Correct |
778 ms |
34944 KB |
Output is correct |
75 |
Correct |
717 ms |
36692 KB |
Output is correct |
76 |
Correct |
542 ms |
35216 KB |
Output is correct |