Submission #897313

#TimeUsernameProblemLanguageResultExecution timeMemory
897313guagua0407Two Transportations (JOI19_transportations)C++17
0 / 100
12 ms24564 KiB
#include "Azer.h" #include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define f first #define s second #define all(x) x.begin(),x.end() #define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); namespace { const int inf=1e9; const int mxn=5e5+5; int n; vector<pair<int,int>> adj[mxn]; int cur=0; int bit=0; int prv=0; int sir=0; vector<int> d; vector<bool> vis; pair<int,int> mn={inf,inf}; void send(int x,int len){ for(int i=len-1;i>=0;i--){ if(x&(1<<len)){ SendA(1); } else{ SendA(0); } } } void relax(){ d[mn.s]=prv+mn.f; prv=d[mn.s]; vis[mn.s]=true; for(auto u:adj[mn.s]){ d[u.f]=min(d[u.f],d[mn.s]+u.s); } cerr<<"A:"<<'\n'; for(int i=0;i<n;i++){ cerr<<d[i]<<' '; } cerr<<'\n'; mn={inf,inf}; for(int i=0;i<n;i++){ if(vis[i]) continue; mn=min(mn,{d[i]-prv,i}); } if(mn.f!=inf){ send(mn.f,9); } } void getdis(){ if(cur==511){ send(mn.s,11); relax(); cur=bit=0; } else{ mn.f=cur; bit=cur=0; sir=1; } } void getid(){ mn.s=cur; relax(); bit=cur=0; sir=0; } } // namespace void InitA(int N, int A, std::vector<int> U, std::vector<int> V, std::vector<int> C) { n=N; for(int i=0;i<A;i++){ int a=U[i]; int b=V[i]; int c=C[i]; adj[a].push_back({b,c}); adj[b].push_back({a,c}); } d=vector<int>(n,inf); vis=vector<bool>(n,false); d[0]=0; vis[0]=true; for(auto u:adj[0]){ d[u.f]=min(d[u.f],d[0]+u.s); } for(int i=0;i<n;i++){ if(vis[i]) continue; mn=min(mn,{d[i]-prv,i}); } send(mn.f,9); } void ReceiveA(bool x) { cur=cur*2+x; bit++; if(bit==9 and sir==0){ getdis(); } else if(bit==11){ getid(); } } std::vector<int> Answer() { return d; }
#include "Baijan.h" #include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define f first #define s second #define all(x) x.begin(),x.end() #define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); namespace { const int inf=1e9; const int mxn=5e5+5; int n; vector<pair<int,int>> adj[mxn]; int cur=0; int bit=0; int prv=0; int sir=0; vector<int> d; vector<bool> vis; pair<int,int> mn={inf,inf}; void send(int x,int len){ for(int i=len-1;i>=0;i--){ if(x&(1<<len)){ SendB(1); } else{ SendB(0); } } } void relax(){ d[mn.s]=prv+mn.f; prv=d[mn.s]; vis[mn.s]=true; for(auto u:adj[mn.s]){ d[u.f]=min(d[u.f],d[mn.s]+u.s); } mn={inf,inf}; for(int i=0;i<n;i++){ if(vis[i]) continue; mn=min(mn,{d[i]-prv,i}); } } void getdis(){ if(mn.f>cur){ send(511,9); cur=bit=0; sir=1; } else{ send(mn.f,9); send(mn.s,11); relax(); cur=bit=0; } } void getid(){ mn.s=cur; relax(); bit=cur=0; sir=0; } } // namespace void InitB(int N, int B, std::vector<int> U, std::vector<int> V, std::vector<int> C) { n=N; for(int i=0;i<B;i++){ int a=U[i]; int b=V[i]; int c=C[i]; adj[a].push_back({b,c}); adj[b].push_back({a,c}); } d=vector<int>(n,inf); vis=vector<bool>(n,false); d[0]=0; vis[0]=true; for(auto u:adj[0]){ d[u.f]=min(d[u.f],d[0]+u.s); } for(int i=0;i<n;i++){ if(vis[i]) continue; mn=min(mn,{d[i]-prv,i}); } } void ReceiveB(bool x) { cur=cur*2+x; bit++; if(bit==9 and sir==0){ getdis(); } else if(bit==11){ getid(); } }
#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...