Submission #985325

#TimeUsernameProblemLanguageResultExecution timeMemory
985325user736482Two Transportations (JOI19_transportations)C++17
100 / 100
946 ms59916 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={0}; void sendInt(int a,int rozmiar){ vector<bool>v; int c=a; 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 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 wczyt11(){ stan=9; last+=czyt; //cout<<czyt2<<" czyt2 "; answer[czyt2]=last; odwiedzone[czyt2]=1; for (int i = 0; i < (int)sasiedzi[czyt2].size(); i++) { pq.push({ sasiedzi[czyt2][i].first + last,sasiedzi[czyt2][i].second }); } czyt2=0; while(!pq.empty() && odwiedzone[pq.top().second]) pq.pop(); if(pq.empty()) pq.push({9999999,2137}); //cout<<pq.top().first<<" "<<last<<"a\n"; sendInt(min(510,pq.top().first-last),9); czyt=0; } void wczyt9(){ //cout<<n<<" n "; if(liczbaodwiedzonych==n) return; liczbaodwiedzonych++; //cout<<liczbaodwiedzonych<<"\n"; 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; last=pq.top().first; czyt=0; sendInt(pq.top().second,11); pair<int,int>pqtop=pq.top(); pq.pop(); 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 }); } while(!pq.empty() && odwiedzone[pq.top().second]) pq.pop(); if(pq.empty()) pq.push({9999999,2137}); //cout<<pq.top().first<<" "<<last<<"a\n"; sendInt(min(510,pq.top().first-last),9); } else{ stan=11; } } void ReceiveA(bool y){ //cout<<y; if(stan == 9){ czyt*=2; czyt+=y; akbit++; if(akbit==9){ //cout<<" "<<czyt<<" b "; akbit=0; wczyt9(); } } if(stan==11){ czyt2*=2; czyt2+=y; akbit++; if(akbit==12){ czyt2=czyt2%2048; //cout<<" "<<czyt2<<" b "; akbit=0; wczyt11(); } } } vector<int>Answer(){ return answer; }
#include<bits/stdc++.h> #include "Baijan.h" using namespace std; namespace{ 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={0}; void sendInt(int a,int rozmiar){ vector<bool>v; int c=a; 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]); //cout<<v[i]; } //cout<<" "<<c<<" a "; } void wczyt11(){ //cout<<"bdostal "<<czyt2<<"\n"; //cout<<answer[0]<<" "<<answer[1]<<" "<<answer[2]<<" "<<answer[3]<<"\n"; stan=9; last+=czyt; answer[czyt2]=last; odwiedzone[czyt2]=1; for (int i = 0; i < (int)sasiedzi[czyt2].size(); i++) { pq.push({ sasiedzi[czyt2][i].first + last,sasiedzi[czyt2][i].second }); //cout<<sasiedzi[czyt2][i].first + last<<" "<<sasiedzi[czyt2][i].second<<"\n"; } czyt2=0; while(!pq.empty() && odwiedzone[pq.top().second]) pq.pop(); if(pq.empty()) pq.push({9999999,2137}); //cout<<pq.top().first<<" "<<last<<"b\n"; sendInt(min(510,pq.top().first-last),9); czyt=0; } void wczyt9(){ //cout<<pq.top().first<<" "<<pq.top().second<<"\n"; if(liczbaodwiedzonych==n) return; liczbaodwiedzonych++; //cout<<answer[0]<<" "<<answer[1]<<" "<<answer[2]<<" "<<answer[3]<<" "<<answer[4]<<" "<<answer[5]<<" "<<answer[6]<<" "<<liczbaodwiedzonych<<"\n"; 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; last=pq.top().first; czyt=0; sendInt(pq.top().second,11); pair<int,int>pqtop=pq.top(); pq.pop(); 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 }); } while(!pq.empty() && odwiedzone[pq.top().second]) pq.pop(); if(pq.empty()) pq.push({9999999,2137}); //cout<<pq.top().first<<" "<<last<<"b\n"; sendInt(min(510,pq.top().first-last),9); } else{ stan=11; //cout<<akbit<<"p"; } }} 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){ czyt=czyt%2048; akbit=0; wczyt9(); } } if(stan==11){ czyt2*=2; czyt2+=y; akbit++; if(akbit==12){ czyt2=czyt2%2048; akbit=0; wczyt11(); } } }

Compilation message (stderr)

Azer.cpp: In function 'void sendInt(int, int)':
Azer.cpp:14:5: warning: unused variable 'c' [-Wunused-variable]
   14 | int c=a;
      |     ^

Baijan.cpp: In function 'void {anonymous}::sendInt(int, int)':
Baijan.cpp:14:5: warning: unused variable 'c' [-Wunused-variable]
   14 | int c=a;
      |     ^
#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...