This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |