Submission #708391

#TimeUsernameProblemLanguageResultExecution timeMemory
708391alvingogoTwo Transportations (JOI19_transportations)C++14
100 / 100
857 ms48856 KiB
#include <bits/stdc++.h> #include "Azer.h" #pragma GCC optimize("Ofast") #define AquA cin.tie(0);ios_base::sync_with_stdio(0); #define fs first #define sc second #define p_q priority_queue using namespace std; namespace{ vector<vector<pair<int,int> > > gg; int n,m; vector<int> dis,vis; void send(int a,int i){ i--; for(;i>=0;i--){ SendA((a>>i)&1); } } int nw=0,cnt=0,tp=0,x=0,pre=0; } void InitA(int N, int A, std::vector<int> U, std::vector<int> V, std::vector<int> C){ send(0,9); n=N; m=A; gg.resize(n); dis.resize(n,1e9); vis.resize(n); dis[0]=0; for(int i=0;i<m;i++){ gg[U[i]].push_back({V[i],C[i]}); gg[V[i]].push_back({U[i],C[i]}); } } void ReceiveA(bool y){ nw=2*nw+y; cnt++; if(tp==0){ if(cnt==9){ if(nw<=x){ tp=1; pre+=nw; } else{ nw=x; pre+=nw; for(int i=0;i<n;i++){ if(!vis[i] && dis[i]==pre){ send(i,11); dis[i]=pre; vis[i]=1; for(auto h:gg[i]){ dis[h.fs]=min(dis[h.fs],dis[i]+h.sc); } int mm=1e9; int uu=0; for(int j=0;j<n;j++){ if(!vis[j] && dis[j]<mm){ mm=dis[j]; } if(!vis[j]){ uu++; } } if(!uu){ return; } x=min(511,mm-pre); send(x,9); break; } } } nw=0; cnt=0; } } else if(tp==1){ if(cnt==11){ dis[nw]=pre; vis[nw]=1; for(auto h:gg[nw]){ dis[h.fs]=min(dis[h.fs],dis[nw]+h.sc); } int mm=1e9; int uu=0; for(int i=0;i<n;i++){ if(!vis[i] && dis[i]<mm){ mm=dis[i]; } if(!vis[i]){ uu++; } } if(!uu){ return; } x=min(511,mm-pre); send(x,9); cnt=0; nw=0; tp=0; } } } std::vector<int> Answer(){ return dis; }
#include <bits/stdc++.h> #include "Baijan.h" #pragma GCC optimize("Ofast") #define AquA cin.tie(0);ios_base::sync_with_stdio(0); #define fs first #define sc second #define p_q priority_queue using namespace std; namespace{ vector<vector<pair<int,int> > > gg; int n,m; vector<int> dis,vis; void send(int a,int i){ i--; for(;i>=0;i--){ SendB((a>>i)&1); } } int nw=0,cnt=0,tp=0,x=0,pre=0; int cz=0; } void InitB(int N, int B, std::vector<int> S, std::vector<int> T, std::vector<int> D){ send(0,9); n=N; m=B; gg.resize(n); dis.resize(n,1e9); vis.resize(n); dis[0]=0; for(int i=0;i<m;i++){ gg[S[i]].push_back({T[i],D[i]}); gg[T[i]].push_back({S[i],D[i]}); } } void ReceiveB(bool y){ nw=2*nw+y; cnt++; if(tp==0){ if(cnt==9){ if(nw<x){ tp=1; pre+=nw; } else{ nw=x; pre+=nw; for(int i=0;i<n;i++){ if(!vis[i] && dis[i]==pre){ send(i,11); dis[i]=pre; vis[i]=1; for(auto h:gg[i]){ dis[h.fs]=min(dis[h.fs],dis[i]+h.sc); } int mm=1e9; int uu=0; for(int j=0;j<n;j++){ if(!vis[j] && dis[j]<mm){ mm=dis[j]; } if(!vis[j]){ uu++; } } if(!uu){ return; } x=min(511,mm-pre); send(x,9); break; } } } nw=0; cnt=0; } } else if(tp==1){ if(cnt==11){ dis[nw]=pre; vis[nw]=1; for(auto h:gg[nw]){ dis[h.fs]=min(dis[h.fs],dis[nw]+h.sc); } int mm=1e9; int uu=0; for(int i=0;i<n;i++){ if(!vis[i] && dis[i]<mm){ mm=dis[i]; } if(!vis[i]){ uu++; } } if(!uu){ return; } x=min(511,mm-pre); send(x,9); cnt=0; nw=0; tp=0; } } }

Compilation message (stderr)

Baijan.cpp:21:9: warning: '{anonymous}::cz' defined but not used [-Wunused-variable]
   21 |     int cz=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...