Submission #779569

#TimeUsernameProblemLanguageResultExecution timeMemory
779569bachhoangxuanTwo Transportations (JOI19_transportations)C++17
0 / 100
381 ms792 KiB
#include "Azer.h" #include <bits/stdc++.h> using namespace std; #define pii pair<int,int> namespace { int N,cnt=0,pu=0,pv=0,cur=0,lst=0; vector<bool> used; vector<int> dist; vector<vector<pii>> edge; void d(int u){ used[u]=true;lst=dist[u]; for(auto [v,w]:edge[u]) dist[v]=min(dist[u],w); } void Send(){ int u=-1; for(int i=0;i<N;i++) if(!used[i] && (u==-1 || dist[i]<dist[u])) u=i; if(u==-1) return; int x=min(dist[u]-lst,511);pu=u; for(int i=0;i<9;i++) SendA((x>>i)&1); } } // namespace void InitA(int N, int A, vector<int> U, vector<int> V, vector<int> C) { ::N=N; used.resize(N); dist.assign(N,1e9); edge.resize(N); for(int i=0;i<A;i++){ edge[U[i]].push_back({V[i],C[i]}); edge[V[i]].push_back({U[i],C[i]}); } dist[0]=0;d(0); Send(); } void ReceiveA(bool x) { if(cnt<9){ if(x) cur|=(1<<cnt); if(++cnt==9){ cur+=lst; if(dist[pu]<=cur){ for(int i=0;i<11;i++) SendA((pu>>i)&1); d(pu);Send();cnt=cur=0; } else pv=0; } } else{ if(x) pv|=(1<<(cnt-9)); if(++cnt==20){ dist[pv]=min(dist[pv],cur); d(pv);Send(); cnt=cur=0; } } } vector<int> Answer() { return dist; }
#include "Baijan.h" #include <bits/stdc++.h> using namespace std; #define pii pair<int,int> namespace { int N,cnt=0,pu=0,pv=0,cur=0,lst=0; vector<bool> used; vector<int> dist; vector<vector<pii>> edge; void d(int u){ used[u]=true;lst=dist[u]; for(auto [v,w]:edge[u]) dist[v]=min(dist[u],w); } void Send(){ int u=-1; for(int i=0;i<N;i++) if(!used[i] && (u==-1 || dist[i]<dist[u])) u=i; if(u==-1) return; int x=min(dist[u]-lst,511);pu=u; for(int i=0;i<9;i++) SendB((x>>i)&1); } } // namespace void InitB(int N, int B, vector<int> U, vector<int> V, vector<int> C) { ::N=N; used.resize(N); dist.assign(N,1e9); edge.resize(N); for(int i=0;i<B;i++){ edge[U[i]].push_back({V[i],C[i]}); edge[V[i]].push_back({U[i],C[i]}); } dist[0]=0;d(0); Send(); } void ReceiveB(bool x) { if(cnt<9){ if(x) cur|=(1<<cnt); if(++cnt==9){ cur+=lst; if(dist[pu]<=cur){ for(int i=0;i<11;i++) SendB((pu>>i)&1); d(pu);Send();cnt=cur=0; } else pv=0; } } else{ if(x) pv|=(1<<(cnt-9)); if(++cnt==20){ dist[pv]=min(dist[pv],cur); d(pv);Send(); cnt=cur=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...