Submission #984571

#TimeUsernameProblemLanguageResultExecution timeMemory
984571user736482Two Transportations (JOI19_transportations)C++17
0 / 100
6 ms1040 KiB
#include<bits/stdc++.h> #include<Azer.h> using namespace std; priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>pq; int stan=9,akbit,czyt,czyt2,liczbaodwiedzonych=1,n,last; int odwiedzone[2137 + 1]; vector<pair<int, int>> sasiedzi[2000]; vector<int>answer; void sendInt(int a,int rozmiar){ vector<bool>v; for(int i=0;i<rozmiar;i++){ v.push_back(a%2); a/=2; } for(int i=rozmiar-1;i>=0;i++){ SendA(v[i]); } } void InitA(int N, int A, vector<int>U, vector<int>V, vector<int>C) { odwiedzone[0] = 1; n = N; for (int i = 1; i < N; i++) answer.push_back(9999999); 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]); } pq.push({9999999,2137}); sendInt(min(510,pq.top().first),9); } void ReceiveA(bool x){ if(stan == 9){ czyt*=2; czyt+=x; akbit++; if(akbit==9){ if(liczbaodwiedzonych==n) return; liczbaodwiedzonych++; while(!pq.empty() && odwiedzone[pq.top().second]) pq.pop(); if(pq.empty()) pq.push({9999999,2137}); if(pq.top().first-last>czyt){ odwiedzone[pq.top().second] = 1; answer[pq.top().second] = pq.top().first; for (int i = 0; i < (int)sasiedzi[pq.top().second].size(); i++) { pq.push({ sasiedzi[pq.top().second][i].first + pq.top().first + last,sasiedzi[pq.top().second][i].second }); } last+=pq.top().first; czyt=0; sendInt(pq.top().second,11); pq.pop(); while(!pq.empty() && odwiedzone[pq.top().second]) pq.pop(); if(pq.empty()) pq.push({9999999,2137}); sendInt(min(510,pq.top().first-last),9); } else{ stan=11; } akbit=0; } } if(stan==11){ czyt2*=2; czyt2+=x; akbit++; if(akbit==11){ stan=9; akbit=0; answer[czyt2]=czyt+last; for (int i = 0; i < (int)sasiedzi[czyt2].size(); i++) { pq.push({ sasiedzi[czyt2][i].first + czyt + last,sasiedzi[pq.top().second][i].second }); } czyt2=0; while(!pq.empty() && odwiedzone[pq.top().second]) pq.pop(); if(pq.empty()) pq.push({9999999,2137}); sendInt(min(pq.top().first-last-czyt,510),9); last+=czyt; czyt=0; } } } vector<int>Answer(){ return answer; }
#include<bits/stdc++.h> #include<Baijan.h> using namespace std; priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>pq; int stan=9,akbit,czyt,czyt2,liczbaodwiedzonych=1,n,last; int odwiedzone[2137 + 1]; vector<pair<int, int>> sasiedzi[2000]; vector<int>answer; void sendInt(int a,int rozmiar){ vector<bool>v; for(int i=0;i<rozmiar;i++){ v.push_back(a%2); a/=2; } for(int i=rozmiar-1;i>=0;i++){ SendB(v[i]); } } void InitB(int N, int B, vector<int>U, vector<int>V, vector<int>C) { odwiedzone[0] = 1; n = N; for (int i = 1; i < N; i++) answer.push_back(9999999); 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]); } pq.push({9999999,2137}); sendInt(min(510,pq.top().first),9); } void ReceiveB(bool y){ if(stan == 9){ czyt*=2; czyt+=y; akbit++; if(akbit==9){ if(liczbaodwiedzonych==n) return; liczbaodwiedzonych++; while(!pq.empty() && odwiedzone[pq.top().second]) pq.pop(); if(pq.empty()) pq.push({9999999,2137}); if(pq.top().first-last>czyt){ odwiedzone[pq.top().second] = 1; answer[pq.top().second] = pq.top().first; for (int i = 0; i < (int)sasiedzi[pq.top().second].size(); i++) { pq.push({ sasiedzi[pq.top().second][i].first + pq.top().first + last,sasiedzi[pq.top().second][i].second }); } last+=pq.top().first; czyt=0; sendInt(pq.top().second,11); pq.pop(); while(!pq.empty() && odwiedzone[pq.top().second]) pq.pop(); if(pq.empty()) pq.push({9999999,2137}); sendInt(min(510,pq.top().first-last),9); } else{ stan=11; } akbit=0; } } if(stan==11){ czyt2*=2; czyt2+=y; akbit++; if(akbit==11){ stan=9; akbit=0; answer[czyt2]=czyt+last; for (int i = 0; i < (int)sasiedzi[czyt2].size(); i++) { pq.push({ sasiedzi[czyt2][i].first + czyt + last,sasiedzi[pq.top().second][i].second }); } czyt2=0; while(!pq.empty() && odwiedzone[pq.top().second]) pq.pop(); if(pq.empty()) pq.push({9999999,2137}); sendInt(min(510,pq.top().first-last-czyt),9); last+=czyt; czyt=0; } } }
#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...