제출 #206613

#제출 시각아이디문제언어결과실행 시간메모리
206613autumn_eelTwo Transportations (JOI19_transportations)C++14
100 / 100
2086 ms85808 KiB
#include "Azer.h" #include <bits/stdc++.h> #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; typedef pair<int,int>P; const int INF=0x3f3f3f3f; namespace { int N; vector<P>E[3000]; bool used[3000]; int d[3000]; int Min,id; int Max; void Send(int n,int x){ for(int i=n-1;i>=0;i--){ SendA(x>>i&1); } } struct Receiver{ int n,cur,x; bool flag; void Init(int N){ n=N; cur=n-1; x=0; flag=true; } bool Read(int b){ x|=(b<<cur); if(cur==0){ flag=false; return true; } cur--; return false; } }Rcost,Rid; void Update(int v,int cost){ used[v]=true; d[v]=cost; Max=cost; for(auto p:E[v]){ d[p.second]=min(d[p.second],cost+p.first); } Min=INF;id=-1; rep(i,N){ if(!used[i]&&Min>d[i]){ Min=d[i]; id=i; } } if(Min!=INF){ int d=Min-Max; if(Min==(1<<20)-1)d=(1<<9)-1; Send(9,d); Rcost.Init(9); } } } void InitA(int N,int A,vector<int>U,vector<int>V,vector<int>C){ ::N=N; rep(i,A){ E[U[i]].push_back(P(C[i],V[i])); E[V[i]].push_back(P(C[i],U[i])); } rep(i,N)d[i]=(1<<20)-1; Update(0,0); } void ReceiveA(bool x){ if(Rcost.flag){ if(!Rcost.Read(x))return; if(Rcost.x+Max<Min){ Rid.Init(11); } else{ Send(11,id); Update(id,Min); } } else if(Rid.flag){ if(!Rid.Read(x))return; Update(Rid.x,Rcost.x+Max); } } vector<int>Answer(){ vector<int>ans(N); rep(i,N){ ans[i]=d[i]; } return ans; }
#include "Baijan.h" #include <bits/stdc++.h> #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; typedef pair<int,int>P; const int INF=0x3f3f3f3f; namespace { int N; vector<P>E[3000]; bool used[3000]; int d[3000]; int Min,id; int Max; void Send(int n,int x){ for(int i=n-1;i>=0;i--){ SendB(x>>i&1); } } struct Receiver{ int n,cur,x; bool flag; void Init(int N){ n=N; cur=n-1; x=0; flag=true; } bool Read(int b){ x|=(b<<cur); if(cur==0){ flag=false; return true; } cur--; return false; } }Rcost,Rid; void Update(int v,int cost){ used[v]=true; d[v]=cost; Max=cost; for(auto p:E[v]){ d[p.second]=min(d[p.second],cost+p.first); } Min=INF;id=-1; rep(i,N){ if(!used[i]&&Min>d[i]){ Min=d[i]; id=i; } } if(Min!=INF){ int d=Min-Max; if(Min==(1<<20)-1)d=(1<<9)-1; Send(9,d); Rcost.Init(9); } } } void InitB(int N,int B,vector<int>S,vector<int>T,vector<int> D) { ::N=N; rep(i,B){ E[S[i]].push_back(P(D[i],T[i])); E[T[i]].push_back(P(D[i],S[i])); } rep(i,N)d[i]=(1<<20)-1; Update(0,0); } void ReceiveB(bool x){ if(Rcost.flag){ if(!Rcost.Read(x))return; if(Rcost.x+Max<=Min){ Rid.Init(11); } else{ Send(11,id); Update(id,Min); } } else if(Rid.flag){ if(!Rid.Read(x))return; Update(Rid.x,Rcost.x+Max); } }
#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...