Submission #984032

#TimeUsernameProblemLanguageResultExecution timeMemory
984032user736482Two Transportations (JOI19_transportations)C++17
0 / 100
186 ms588 KiB
#include <bits/stdc++.h> #include<Azer.h> using namespace std; vector<int> answer,akliczby; int akwaga=1,akbit=-1,ak,state,rec,dist,ileod,n,previ; vector<bool>tym; bool odwiedzone[2000]; pair<int,int>pqtop; vector<pair<int,int>> sasiedzi[2000]; priority_queue<pair<int,int>>pq; void InitA(int N, int A, vector<int>U,vector<int>V,vector<int>C ){ odwiedzone[0]=1; n=N; for(int i=0;i<N;i++){ answer.push_back(9999999); } answer[0]=0; for(int i=0;i<A;i++){ sasiedzi[U[i]].push_back({C[i],V[i]}); sasiedzi[V[i]].push_back({C[i],U[i]}); } for(int i=0;i<(int)sasiedzi[0].size();i++){ pq.push(sasiedzi[0][i]); } pqtop=pq.top(); ak=pqtop.first; for(int i=0;i<9;i++){ SendA(ak%2); ak/=2; } } void ReceiveA(bool x){ if(state==0){ tym.push_back(x); akbit++; if(akbit==9){ akbit=0; rec=0; for(int i=8;i>=0;i--){ rec*=2; rec+=tym[i]; previ+=rec; } /*!!!!!!!!*/if(rec<pqtop.first){ state=1; dist=rec; } else{ previ+=pqtop.first; pq.pop(); ileod++; odwiedzone[pqtop.second]=1; answer[pqtop.second]=pqtop.first; for(int i=0;i<(int)sasiedzi[pqtop.second].size();i++){ pq.push({sasiedzi[pqtop.second][i].first+pqtop.first,sasiedzi[pqtop.second][i].second}); } ak=pqtop.second; for(int i=0;i<11;i++){ SendA(ak%2); ak/=2; } state=2; } } } if(state==1){ tym.push_back(x); akbit++; if(akbit==11){ akbit=0; rec=0; for(int i=10;i>=0;i--){ rec*=2; rec+=tym[i]; } ileod++; odwiedzone[rec]=1; answer[rec]=dist; for(int i=0;i<(int)sasiedzi[rec].size();i++){ pq.push({sasiedzi[rec][i].first+dist,sasiedzi[rec][i].second}); } } pqtop=pq.top(); while(odwiedzone[pqtop.second]){ pq.pop(); pqtop=pq.top(); } ak=pqtop.first-previ; state=0; for(int i=0;i<9;i++){ SendA(ak%2); ak/=2; } } if(state==2){ tym.push_back(x); akbit++; if(akbit==9){ akbit=0; rec=0; for(int i=8;i>=0;i--){ rec*=2; rec+=tym[i]; } pqtop=pq.top(); while(odwiedzone[pqtop.second]){ pq.pop(); pqtop=pq.top(); } ak=pqtop.first; for(int i=0;i<9;i++){ SendA(ak%2); ak/=2; } /*!!!!!!!!*/if(rec<pqtop.first){ state=1; dist=rec; previ+=rec; } else{ previ+=pqtop.first; pq.pop(); ileod++; odwiedzone[pqtop.second]=1; answer[pqtop.second]=pqtop.first; for(int i=0;i<(int)sasiedzi[pqtop.second].size();i++){ pq.push({sasiedzi[pqtop.second][i].first+pqtop.first,sasiedzi[pqtop.second][i].second}); } ak=pqtop.second-previ; for(int i=0;i<11;i++){ SendA(ak%2); ak/=2; } state=2; } } } } vector<int> Answer(){ return answer; }
#include<bits/stdc++.h> #include<Baijan.h> using namespace std; vector<int>answer; int odwiedzone[2000],ak,n,state,rec,dist,akbit,ileod=1,previ; vector<bool>tym; vector<pair<int,int>> sasiedzi[2000]; priority_queue<pair<int,int>>pq; pair<int,int>pqtop; void InitB(int N, int B, vector<int>U,vector<int>V,vector<int>C ){ set<pair<int,pair<int,int>>>krawedzie; int ak; for(int i=0;i<B;i++){ krawedzie.insert({C[i],{U[i],V[i]}}); } odwiedzone[0]=1; n=N; for(int i=0;i<N;i++){ answer.push_back(9999999); } answer[0]=0; for(int i=0;i<B;i++){ sasiedzi[U[i]].push_back({C[i],V[i]}); sasiedzi[V[i]].push_back({C[i],U[i]}); } for(int i=0;i<(int)sasiedzi[0].size();i++){ pq.push(sasiedzi[0][i]); } pqtop=pq.top(); ak=pqtop.first; for(int i=0;i<9;i++){ SendB(ak%2); ak/=2; } } void ReceiveB(bool y){ if(state==0){ tym.push_back(y); akbit++; if(akbit==9){ akbit=0; rec=0; for(int i=8;i>=0;i--){ rec*=2; rec+=tym[i]; } /*!!!!!!!!*/if(rec<=pqtop.first){ state=1; dist=rec; previ+=rec; } else{ pq.pop(); previ+=pqtop.first; ileod++; odwiedzone[pqtop.second]=1; answer[pqtop.second]=pqtop.first; for(int i=0;i<(int)sasiedzi[pqtop.second].size();i++){ pq.push({sasiedzi[pqtop.second][i].first+pqtop.first,sasiedzi[pqtop.second][i].second}); } ak=pqtop.second; for(int i=0;i<11;i++){ SendB(ak%2); ak/=2; } state=2; } } } if(state==1){ tym.push_back(y); akbit++; if(akbit==11){ akbit=0; rec=0; for(int i=10;i>=0;i--){ rec*=2; rec+=tym[i]; } ileod++; odwiedzone[rec]=1; answer[rec]=dist; for(int i=0;i<(int)sasiedzi[rec].size();i++){ pq.push({sasiedzi[rec][i].first+dist,sasiedzi[rec][i].second}); } } while(odwiedzone[pqtop.second]){ pq.pop(); pqtop=pq.top(); } pqtop=pq.top(); ak=pqtop.first-previ; state=0; for(int i=0;i<9;i++){ SendB(ak%2); ak/=2; } } if(state==2){ tym.push_back(y); akbit++; if(akbit==9){ akbit=0; rec=0; for(int i=8;i>=0;i--){ rec*=2; rec+=tym[i]; } while(odwiedzone[pqtop.second]){ pq.pop(); pqtop=pq.top(); } pqtop=pq.top(); ak=pqtop.first-previ; for(int i=0;i<9;i++){ SendB(ak%2); ak/=2; } /*!!!!!!!!*/if(rec<=pqtop.first){ state=1; dist=rec; previ+=rec; } else{ pq.pop(); ileod++; previ+=pqtop.first; odwiedzone[pqtop.second]=1; answer[pqtop.second]=pqtop.first; for(int i=0;i<(int)sasiedzi[pqtop.second].size();i++){ pq.push({sasiedzi[pqtop.second][i].first+pqtop.first,sasiedzi[pqtop.second][i].second}); } ak=pqtop.second; for(int i=0;i<11;i++){ SendB(ak%2); ak/=2; } state=2; } } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...