이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "Azer.h"
#include <bits/stdc++.h>
using namespace std;
namespace Azer{
using P = pair<int,int>;
const int INF=INT_MAX/2;
int n;
vector<int> dp;
vector<vector<pair<int,int>>> adj;
int dat,counter,last;
priority_queue<P,vector<P>,greater<P>> pq;
void send(int id,int v){
for(int i=0;i<11;i++)SendA(id>>i&1);
for(int i=0;i<9;i++)SendA(v>>i&1);
}
void receive(int id,int dist){
dist+=last;
last=dist;
dp[id]=dist;
for(auto [v,w]:adj[id])if(dp[v]==INF)pq.emplace(dist+w,v);
while(!pq.empty()&&dp[pq.top().second]<INF)pq.pop();
if(pq.empty())return send(0,0);
auto [d,u]=pq.top();
send(u,d-last);
}
}
void InitA(int _n, int a,vector<int> _u,vector<int> _v,vector<int> _c){
using namespace Azer;
dat=counter=0;
n=_n;
dp.assign(n,INF);
adj.assign(n,{});
for(int i=0;i<a;i++){
int u=_u[i],v=_v[i],c=_c[i];
adj[u].emplace_back(v,c);
adj[v].emplace_back(u,c);
}
dp[0]=0;
for(auto [v,w]:adj[0])pq.emplace(w,v);
if(!pq.empty()){
auto [d,u]=pq.top();
send(u,d);
}else{
send(0,0);
}
}
void ReceiveA(bool x){
using namespace Azer;
dat|=int(x)<<counter;
counter++;
if(counter==20){
receive(dat&2047,dat>>11);
dat=counter=0;
}
}
vector<int> Answer(){
using namespace Azer;
return dp;
}
#include "Baijan.h"
#include <bits/stdc++.h>
using namespace std;
namespace Baijan{
using P = pair<int,int>;
const int INF=INT_MAX/2;
int n;
vector<int> dp;
vector<vector<pair<int,int>>> adj;
int dat,counter,last;
priority_queue<P,vector<P>,greater<P>> pq;
void send(int id,int v){
for(int i=0;i<11;i++)SendB(id>>i&1);
for(int i=0;i<9;i++)SendB(v>>i&1);
}
void receive(int id,int dist){
dist+=last;
pq.emplace(dist,id);
while(!pq.empty()&&dp[pq.top().second]<INF)pq.pop();
if(pq.empty())return;
auto [d,u]=pq.top();
dp[u]=d;
for(auto [v,w]:adj[u])if(dp[v]==INF)pq.emplace(d+w,v);
send(u,d-last);
last=d;
}
}
void InitB(int _n, int b,vector<int> _u,vector<int> _v,vector<int> _c){
using namespace Baijan;
dat=counter=0;
n=_n;
dp.assign(n,INF);
adj.assign(n,{});
for(int i=0;i<b;i++){
int u=_u[i],v=_v[i],c=_c[i];
adj[u].emplace_back(v,c);
adj[v].emplace_back(u,c);
}
dp[0]=0;
for(auto [v,w]:adj[0])pq.emplace(w,v);
}
void ReceiveB(bool x){
using namespace Baijan;
dat|=int(x)<<counter;
counter++;
if(counter==20){
receive(dat&2047,dat>>11);
dat=counter=0;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |