이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//Be Name KHODA
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include "Azer.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define pp pop_back
#define lb lower_bound
#define ub upper_bound
#define cl clear
#define bg begin
#define arr(x) array<int , x>
#define endl '\n'
int nA , mA , dstA[2000];
vector<arr(2)> gA[2000];
set<arr(2)> qA;
int lstA = 0;
int rcvA[3] , xxA[2];
vector<int> AA;
void sendInfA(int x , int len){
x = min(x , 501);
for(int bit = len - 1 ; bit >= 0 ; bit--) SendA((x >> bit) & 1);
}
vector<int> Answer(){
return AA;
}
void addVtxA(int v , int x){
if(v >= nA) exit(0);
qA.erase({dstA[v] , v});
dstA[v] = x , lstA = x;
for(auto &e : gA[v]){
if(dstA[e[0]] > dstA[v] + e[1]){
qA.erase({dstA[e[0]] , e[0]});
dstA[e[0]] = dstA[v] + e[1];
qA.insert({dstA[e[0]] , e[0]});
}
}
if(qA.empty()){
for(int i = 0 ; i < nA ; i++) AA.pb(dstA[i]);
return;
}
auto itr = qA.bg();
rcvA[0] = 9 , rcvA[1] = 0 , rcvA[2] = 0;
xxA[0] = (*itr)[1] , xxA[1] = (*itr)[0] - lstA;
sendInfA((*itr)[0] - lstA , 9);
}
void gotLenA(int len){
if(xxA[1] <= len){
sendInfA(xxA[0] , 11);
addVtxA(xxA[0] , xxA[1] + lstA);
}else{
xxA[1] = len , rcvA[0] = 11 , rcvA[1] = 0 , rcvA[2] = 1;
}
}
void ReceiveA(bool x){
rcvA[1] += (x << (rcvA[0] - 1));
if(--rcvA[0] == 0){
if(rcvA[2] == 0) gotLenA(rcvA[1]);
else{
addVtxA(rcvA[1] , xxA[1] + lstA);
}
}
}
void InitA(int N , int A , vector<int> U , vector<int> V , vector<int> C){
nA = N , mA = A;
fill(&dstA[0] , &dstA[nA] , int(1e9));
for(int v = 0 ; v < nA ; v++) qA.insert({dstA[v] , v});
for(int i = 0 ; i < mA ; i++) gA[U[i]].pb({V[i] , C[i]}) , gA[V[i]].pb({U[i] , C[i]});
addVtxA(0 , 0);
}
//Be Name KHODA
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include "Baijan.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define pp pop_back
#define lb lower_bound
#define ub upper_bound
#define cl clear
#define bg begin
#define arr(x) array<int , x>
#define endl '\n'
int nB , mB , dstB[2000];
vector<arr(2)> gB[2000];
set<arr(2)> qB;
int lstB = 0;
int rcvB[3] , xxB[2];
void sendInfB(int x , int len){
x = min(x , 501);
for(int bit = len - 1 ; bit >= 0 ; bit--) SendB((x >> bit) & 1);
}
void addVtxB(int v , int x){
if(v >= nB) exit(0);
qB.erase({dstB[v] , v});
dstB[v] = x , lstB = x;
for(auto &e : gB[v]){
if(dstB[e[0]] > dstB[v] + e[1]){
qB.erase({dstB[e[0]] , e[0]});
dstB[e[0]] = dstB[v] + e[1];
qB.insert({dstB[e[0]] , e[0]});
}
}
auto itr = qB.bg();
rcvB[0] = 9 , rcvB[1] = 0 , rcvB[2] = 0;
xxB[0] = (*itr)[1] , xxB[1] = (*itr)[0] - lstB;
}
void gotLenB(int len){
if(xxB[1] <= len){
sendInfB(xxB[1] , 9);
sendInfB(xxB[1] , 11);
addVtxB(xxB[0] , xxB[1] + lstB);
}else{
int d = xxB[1];
rcvB[0] = 11 , rcvB[1] = 0 , rcvB[2] = 1 , xxB[1] = len;
sendInfB(d , 9);
}
}
void ReceiveB(bool x){
rcvB[1] += (x << (rcvB[0] - 1));
if(--rcvB[0] == 0){
if(rcvB[2] == 0) gotLenB(rcvB[1]);
else addVtxB(rcvB[1] , xxB[1] + lstB);
}
}
void InitB(int N , int B , vector<int> S , vector<int> T , vector<int> D){
nB = N , mB = B;
fill(&dstB[0] , &dstB[nB] , int(1e9));
for(int v = 0 ; v < nB ; v++) qB.insert({dstB[v] , v});
for(int i = 0 ; i < mB ; i++) gB[T[i]].pb({S[i] , D[i]}) , gB[S[i]].pb({T[i] , D[i]});
addVtxB(0 , 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... |