Submission #708235

#TimeUsernameProblemLanguageResultExecution timeMemory
708235alvingogoTwo Transportations (JOI19_transportations)C++14
14 / 100
457 ms27556 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<int> dis; int n; int m; vector<vector<pair<int,int> > > gg; int nw,f=-1,r=-1,c=-1; int cnt=0; int flag=-1; int z=0; } void InitA(int N, int A, std::vector<int> U, std::vector<int> V, std::vector<int> C){ n=N; m=A; gg.resize(n); dis.resize(n,1e9); 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 x){ if(flag==-1){ flag=x; return; } nw=nw*2+x; cnt++; if(flag==0){ if(cnt==20){ dis[z]=nw; nw=0; cnt=0; z++; } } else{ if(cnt==11){ if(f==-1){ f=nw; } else if(r==-1){ r=nw; } else if(c==-1){ c=nw; gg[f].push_back({r,c}); gg[r].push_back({f,c}); f=-1; r=-1; c=-1; } cnt=0; nw=0; } } } std::vector<int> Answer(){ if(flag){ p_q<pair<int,int> > pq; pq.push({0,0}); while(pq.size()){ auto h=pq.top(); pq.pop(); h.fs*=-1; if(h.fs!=dis[h.sc]){ continue; } for(auto y:gg[h.sc]){ if(dis[y.fs]>h.fs+y.sc){ dis[y.fs]=h.fs+y.sc; pq.push({-dis[y.fs],y.fs}); } } } } 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; void send(int a,int i){ i--; for(;i>=0;i--){ SendB((a>>i)&1); } } void InitB(int N, int B, std::vector<int> S, std::vector<int> T, std::vector<int> D){ if(B<=1000){ SendB(1); for(int i=0;i<B;i++){ send(S[i],11); send(T[i],11); send(D[i],11); } } else{ SendB(0); vector<int> dis(N,1e9); vector<vector<pair<int,int> > > gg(N); for(int i=0;i<B;i++){ gg[S[i]].push_back({T[i],D[i]}); gg[T[i]].push_back({S[i],D[i]}); } p_q<pair<int,int> > pq; dis[0]=0; pq.push({0,0}); while(pq.size()){ auto h=pq.top(); pq.pop(); h.fs*=-1; if(h.fs!=dis[h.sc]){ continue; } for(auto y:gg[h.sc]){ if(dis[y.fs]>h.fs+y.sc){ dis[y.fs]=h.fs+y.sc; pq.push({-dis[y.fs],y.fs}); } } } for(int i=0;i<N;i++){ send(dis[i],20); } } } void ReceiveB(bool y){ }
#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...