#include<bits/stdc++.h>
#define MAXN 30007
using namespace std;
int n,k;
bitset<1000> can[MAXN];
bitset<1000> pref[1007],zero;
vector<int> v[MAXN];
int li[MAXN],tim;
void init(int N, int K){
n=N; k=K;
for(int i=0;i<k;i++){
for(int f=i+1;f<k;f++){
can[i][f]=1;
}
}
for(int i=0;i<k;i++){
pref[i][i]=1;
if(i>0)pref[i]|=pref[i-1];
}
}
void update(int x,int s){
if(can[x][s])return;
can[x][s]=1;
li[x]=tim;
for(int i=0;i<v[x].size();i++){
if(li[v[x][i]]==tim)continue;
update(v[x][i],s);
}
}
int check(){
for(int i=0;i<k;i++){
if((can[i]&pref[i])!=zero)return 1;
}
return 0;
}
int add_teleporter(int a, int b){
v[b].push_back(a);
for(int i=0;i<k;i++){
if(can[b][i]==1 and can[a][i]==0){
tim++; update(a,i);
}
}
if(b<k and can[a][b]==0){
tim++; update(a,b);
}
return check();
}
/*int main(){
init(6, 3);
cout<<add_teleporter(3, 4);
cout<<add_teleporter(5, 0);
cout<<add_teleporter(4, 5);
cout<<add_teleporter(5, 3);
cout<<add_teleporter(1, 4);
return 0;
}*/
Compilation message
game.cpp: In function 'void update(int, int)':
game.cpp:34:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | for(int i=0;i<v[x].size();i++){
| ~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1112 KB |
Output is correct |
3 |
Correct |
1 ms |
1112 KB |
Output is correct |
4 |
Correct |
1 ms |
1112 KB |
Output is correct |
5 |
Correct |
1 ms |
1112 KB |
Output is correct |
6 |
Correct |
1 ms |
1112 KB |
Output is correct |
7 |
Correct |
1 ms |
1112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1112 KB |
Output is correct |
3 |
Correct |
1 ms |
1112 KB |
Output is correct |
4 |
Correct |
1 ms |
1112 KB |
Output is correct |
5 |
Correct |
1 ms |
1112 KB |
Output is correct |
6 |
Correct |
1 ms |
1112 KB |
Output is correct |
7 |
Correct |
1 ms |
1112 KB |
Output is correct |
8 |
Correct |
1 ms |
1112 KB |
Output is correct |
9 |
Correct |
0 ms |
1112 KB |
Output is correct |
10 |
Correct |
1 ms |
1040 KB |
Output is correct |
11 |
Correct |
1 ms |
1112 KB |
Output is correct |
12 |
Correct |
1 ms |
1112 KB |
Output is correct |
13 |
Correct |
1 ms |
1112 KB |
Output is correct |
14 |
Correct |
1 ms |
984 KB |
Output is correct |
15 |
Correct |
1 ms |
1112 KB |
Output is correct |
16 |
Correct |
1 ms |
1112 KB |
Output is correct |
17 |
Correct |
1 ms |
1112 KB |
Output is correct |
18 |
Correct |
1 ms |
1112 KB |
Output is correct |
19 |
Correct |
1 ms |
1112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1112 KB |
Output is correct |
3 |
Correct |
1 ms |
1112 KB |
Output is correct |
4 |
Correct |
1 ms |
1112 KB |
Output is correct |
5 |
Correct |
1 ms |
1112 KB |
Output is correct |
6 |
Correct |
1 ms |
1112 KB |
Output is correct |
7 |
Correct |
1 ms |
1112 KB |
Output is correct |
8 |
Correct |
1 ms |
1112 KB |
Output is correct |
9 |
Correct |
0 ms |
1112 KB |
Output is correct |
10 |
Correct |
1 ms |
1040 KB |
Output is correct |
11 |
Correct |
1 ms |
1112 KB |
Output is correct |
12 |
Correct |
1 ms |
1112 KB |
Output is correct |
13 |
Correct |
1 ms |
1112 KB |
Output is correct |
14 |
Correct |
1 ms |
984 KB |
Output is correct |
15 |
Correct |
1 ms |
1112 KB |
Output is correct |
16 |
Correct |
1 ms |
1112 KB |
Output is correct |
17 |
Correct |
1 ms |
1112 KB |
Output is correct |
18 |
Correct |
1 ms |
1112 KB |
Output is correct |
19 |
Correct |
1 ms |
1112 KB |
Output is correct |
20 |
Correct |
1 ms |
1112 KB |
Output is correct |
21 |
Correct |
1 ms |
1200 KB |
Output is correct |
22 |
Correct |
4 ms |
1112 KB |
Output is correct |
23 |
Correct |
1 ms |
1112 KB |
Output is correct |
24 |
Correct |
12 ms |
1368 KB |
Output is correct |
25 |
Correct |
21 ms |
1368 KB |
Output is correct |
26 |
Correct |
11 ms |
1112 KB |
Output is correct |
27 |
Correct |
36 ms |
1372 KB |
Output is correct |
28 |
Correct |
29 ms |
1368 KB |
Output is correct |
29 |
Correct |
36 ms |
1368 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1112 KB |
Output is correct |
3 |
Correct |
1 ms |
1112 KB |
Output is correct |
4 |
Correct |
1 ms |
1112 KB |
Output is correct |
5 |
Correct |
1 ms |
1112 KB |
Output is correct |
6 |
Correct |
1 ms |
1112 KB |
Output is correct |
7 |
Correct |
1 ms |
1112 KB |
Output is correct |
8 |
Correct |
1 ms |
1112 KB |
Output is correct |
9 |
Correct |
0 ms |
1112 KB |
Output is correct |
10 |
Correct |
1 ms |
1040 KB |
Output is correct |
11 |
Correct |
1 ms |
1112 KB |
Output is correct |
12 |
Correct |
1 ms |
1112 KB |
Output is correct |
13 |
Correct |
1 ms |
1112 KB |
Output is correct |
14 |
Correct |
1 ms |
984 KB |
Output is correct |
15 |
Correct |
1 ms |
1112 KB |
Output is correct |
16 |
Correct |
1 ms |
1112 KB |
Output is correct |
17 |
Correct |
1 ms |
1112 KB |
Output is correct |
18 |
Correct |
1 ms |
1112 KB |
Output is correct |
19 |
Correct |
1 ms |
1112 KB |
Output is correct |
20 |
Correct |
1 ms |
1112 KB |
Output is correct |
21 |
Correct |
1 ms |
1200 KB |
Output is correct |
22 |
Correct |
4 ms |
1112 KB |
Output is correct |
23 |
Correct |
1 ms |
1112 KB |
Output is correct |
24 |
Correct |
12 ms |
1368 KB |
Output is correct |
25 |
Correct |
21 ms |
1368 KB |
Output is correct |
26 |
Correct |
11 ms |
1112 KB |
Output is correct |
27 |
Correct |
36 ms |
1372 KB |
Output is correct |
28 |
Correct |
29 ms |
1368 KB |
Output is correct |
29 |
Correct |
36 ms |
1368 KB |
Output is correct |
30 |
Correct |
59 ms |
4176 KB |
Output is correct |
31 |
Correct |
138 ms |
2676 KB |
Output is correct |
32 |
Correct |
147 ms |
6464 KB |
Output is correct |
33 |
Correct |
21 ms |
5712 KB |
Output is correct |
34 |
Correct |
1166 ms |
7248 KB |
Output is correct |
35 |
Correct |
1184 ms |
6496 KB |
Output is correct |
36 |
Correct |
129 ms |
5708 KB |
Output is correct |
37 |
Correct |
1476 ms |
5824 KB |
Output is correct |
38 |
Correct |
870 ms |
6060 KB |
Output is correct |
39 |
Correct |
951 ms |
6300 KB |
Output is correct |
40 |
Correct |
1563 ms |
7336 KB |
Output is correct |
41 |
Correct |
1102 ms |
6224 KB |
Output is correct |
42 |
Correct |
1026 ms |
6352 KB |
Output is correct |
43 |
Correct |
2217 ms |
7356 KB |
Output is correct |
44 |
Correct |
1813 ms |
7308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1112 KB |
Output is correct |
3 |
Correct |
1 ms |
1112 KB |
Output is correct |
4 |
Correct |
1 ms |
1112 KB |
Output is correct |
5 |
Correct |
1 ms |
1112 KB |
Output is correct |
6 |
Correct |
1 ms |
1112 KB |
Output is correct |
7 |
Correct |
1 ms |
1112 KB |
Output is correct |
8 |
Correct |
1 ms |
1112 KB |
Output is correct |
9 |
Correct |
0 ms |
1112 KB |
Output is correct |
10 |
Correct |
1 ms |
1040 KB |
Output is correct |
11 |
Correct |
1 ms |
1112 KB |
Output is correct |
12 |
Correct |
1 ms |
1112 KB |
Output is correct |
13 |
Correct |
1 ms |
1112 KB |
Output is correct |
14 |
Correct |
1 ms |
984 KB |
Output is correct |
15 |
Correct |
1 ms |
1112 KB |
Output is correct |
16 |
Correct |
1 ms |
1112 KB |
Output is correct |
17 |
Correct |
1 ms |
1112 KB |
Output is correct |
18 |
Correct |
1 ms |
1112 KB |
Output is correct |
19 |
Correct |
1 ms |
1112 KB |
Output is correct |
20 |
Correct |
1 ms |
1112 KB |
Output is correct |
21 |
Correct |
1 ms |
1200 KB |
Output is correct |
22 |
Correct |
4 ms |
1112 KB |
Output is correct |
23 |
Correct |
1 ms |
1112 KB |
Output is correct |
24 |
Correct |
12 ms |
1368 KB |
Output is correct |
25 |
Correct |
21 ms |
1368 KB |
Output is correct |
26 |
Correct |
11 ms |
1112 KB |
Output is correct |
27 |
Correct |
36 ms |
1372 KB |
Output is correct |
28 |
Correct |
29 ms |
1368 KB |
Output is correct |
29 |
Correct |
36 ms |
1368 KB |
Output is correct |
30 |
Correct |
59 ms |
4176 KB |
Output is correct |
31 |
Correct |
138 ms |
2676 KB |
Output is correct |
32 |
Correct |
147 ms |
6464 KB |
Output is correct |
33 |
Correct |
21 ms |
5712 KB |
Output is correct |
34 |
Correct |
1166 ms |
7248 KB |
Output is correct |
35 |
Correct |
1184 ms |
6496 KB |
Output is correct |
36 |
Correct |
129 ms |
5708 KB |
Output is correct |
37 |
Correct |
1476 ms |
5824 KB |
Output is correct |
38 |
Correct |
870 ms |
6060 KB |
Output is correct |
39 |
Correct |
951 ms |
6300 KB |
Output is correct |
40 |
Correct |
1563 ms |
7336 KB |
Output is correct |
41 |
Correct |
1102 ms |
6224 KB |
Output is correct |
42 |
Correct |
1026 ms |
6352 KB |
Output is correct |
43 |
Correct |
2217 ms |
7356 KB |
Output is correct |
44 |
Correct |
1813 ms |
7308 KB |
Output is correct |
45 |
Runtime error |
1 ms |
1912 KB |
Execution killed with signal 11 |
46 |
Halted |
0 ms |
0 KB |
- |