# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1035990 | vjudge1 | Two Transportations (JOI19_transportations) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "Baijan.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int>> adj[2010];
int dist[2010],N_;
vector<int>S_bai,T_bai,D_bai;
void InitB(int N, int B, std::vector<int> S, std::vector<int> T,
std::vector<int> D) {
N_=N;
for(int i=0;i<B;i++)
adj[S[i]].push_back({T[i],D[i]}),
adj[T[i]].push_back({S[i],D[i]});
S_bai=S;
T_bai=T;
D_bai=D;
}
void sendnum(int n,int b){
for(int i=b;i--;)
SendB(n>>i&1);
}
void ReceiveB(bool y) {
if(y){
for(int i=0;i<S_bai.size();i++){
sendnum(S_bai[i],11);
sendnum(T_bai[i],11);
sendnum(D_bai[i],9);
}
} else {
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>>pq;
memset(dist,7,sizeof dist);
dist[0]=0;
pq.push({0,0});
while(pq.size()){
auto[d,x]=pq.top();
pq.pop();
if(dist[x]<d)continue;
for(auto [v,w]:adj[x])
if(dist[v]>w+d)
pq.push({dist[v]=w+d,v});
}
for(int i=0;i<N_;i++)
sendnum(dist[i],20);
}
}