Submission #943726

#TimeUsernameProblemLanguageResultExecution timeMemory
943726yeediotTwo Transportations (JOI19_transportations)C++14
0 / 100
262 ms12224 KiB
#include "Azer.h" #include<bits/stdc++.h> using namespace std; #define S second #define F first namespace { const int mxn=5e5+5; int n; vector<pair<int,int>>adj[mxn]; int cur=0; int bit=0; int prv=0; int first=0; int cnt=0; vector<int>dis; vector<bool>vis; pair<int,int>mn={511,511}; void send(int a,int b){ b--; for(;b>=0;b--){ if(a&(1<<b)){ SendA(1); } else{ SendA(0); } } } void gmn(){ dis[mn.S]=prv+mn.F; prv=dis[mn.S]; cnt++; vis[mn.S]=1; for(auto [u,d]:adj[mn.S]){ dis[u]=min(dis[u],dis[mn.S]+d); } mn={511,511}; for(int i=0;i<n;i++){ if(vis[i])continue; mn=min(mn,{dis[i]-prv,i}); } if(cnt)send(mn.F,9); } void gdis(){ if(cur==511){ send(mn.S,11); gmn(); cur=bit=0; } else{ mn.F=cur; first=1; cur=bit=0; } } void gid(){ mn.S=cur; gmn(); cur=bit=0; first=0; } } // namespace void InitA(int N, int A, std::vector<int> U, std::vector<int> V,std::vector<int> C) { for(int i=0;i<A;i++){ adj[V[i]].push_back({U[i],C[i]}); adj[U[i]].push_back({V[i],C[i]}); } n=N; cnt=0; dis=vector<int>(N,1e9); vis=vector<bool>(N,0); dis[0]=0; vis[0]=1; cnt++; int v=0; for(auto [u,d]:adj[v]){ dis[u]=min(dis[u],dis[v]+d); } for(int i=0;i<n;i++){ if(vis[i])continue; mn=min(mn,{dis[i]-prv,i}); } send(mn.F,9); } void ReceiveA(bool x) { cur=cur*2+x; bit++; if(bit==9 and first==0){ gdis(); } else if(bit==11){ gid(); } } std::vector<int> Answer() { return dis; }
#include "Baijan.h" #include<bits/stdc++.h> using namespace std; #define S second #define F first namespace { const int mxn=5e5+5; int n; int cur=0,bit=0,prv=0,first=0; vector<pair<int,int>>adj[mxn]; vector<int>dis; vector<bool>vis; pair<int,int>mn={511,511}; void send(int a,int b){ b--; for(;b>=0;b--){ if(a&(1<<b)){ SendB(1); } else{ SendB(0); } } } void gmn(){ dis[mn.S]=prv+mn.F; prv=dis[mn.S]; vis[mn.S]=1; for(auto [u,d]:adj[mn.S]){ dis[u]=min(dis[u],dis[mn.S]+d); } mn={511,511}; for(int i=0;i<n;i++){ if(vis[i])continue; mn=min(mn,{dis[i]-prv,i}); } } void gdis(){ if(mn.F>cur){ mn.F=cur; send(511,9); cur=bit=0; first=1; } else{ send(mn.F,9); send(mn.S,11); gmn(); cur=bit=0; } } void gid(){ mn.S=cur; gmn(); cur=bit=0; first=0; } } // namespace void InitB(int N, int B, std::vector<int> U, std::vector<int> V,std::vector<int> C) { for(int i=0;i<B;i++){ adj[V[i]].push_back({U[i],C[i]}); adj[U[i]].push_back({V[i],C[i]}); } n=N; dis=vector<int>(N,1e9); vis=vector<bool>(N,0); dis[0]=0; vis[0]=1; int v=0; for(auto [u,d]:adj[v]){ dis[u]=min(dis[u],dis[v]+d); } for(int i=0;i<n;i++){ if(vis[i])continue; mn=min(mn,{dis[i],i}); } } void ReceiveB(bool x) { cur=cur*2+x; bit++; if(bit==9 and first==0){ gdis(); } else if(bit==11){ gid(); } }

Compilation message (stderr)

Azer.cpp: In function 'void {anonymous}::gmn()':
Azer.cpp:34:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   34 |         for(auto [u,d]:adj[mn.S]){
      |                  ^
Azer.cpp: In function 'void InitA(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
Azer.cpp:76:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   76 |     for(auto [u,d]:adj[v]){
      |              ^

Baijan.cpp: In function 'void {anonymous}::gmn()':
Baijan.cpp:29:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   29 |         for(auto [u,d]:adj[mn.S]){
      |                  ^
Baijan.cpp: In function 'void InitB(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
Baijan.cpp:70:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   70 |     for(auto [u,d]:adj[v]){
      |              ^
#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...