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 <bits/stdc++.h>
#include "Azer.h"
using namespace std;
#define st first
#define nd second
typedef long long ll;
int odl=0,nu=0;
int k1=0,k2=0;
int n;
vector<int>w(2000,-1);
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>q;
vector<vector<pair<int,int>>>g;
int ile=1;
vector<int>Answer()
{
vector<int>v(n);
for(int i=0;i<n;i++)
{
v[i]=w[i];
}
return v;
}
void InitA(int N, int A, std::vector<int> U, std::vector<int> V, std::vector<int> C)
{
n=N;
w[0]=0;
for(int i=0;i<n;i++)
{
g.push_back({{}});
}
for(int i=0;i<A;i++)
{
g[U[i]].push_back({C[i],V[i]});
g[V[i]].push_back({C[i],U[i]});
}
for(long unsigned int i=0;i<g[0].size();i++)
{
q.push({g[0][i].st,g[0][i].nd});
}
q.push({1048575,0});
if(ile<n)
{
for(int i=0;i<20;i++)
{
SendA(q.top().st&(1<<i));
}
for(int i=0;i<11;i++)
{
SendA(q.top().nd&(1<<i));
}
}
}
void ReceiveA(bool x)
{
if(k1<20)
{
if(x)
{
odl+=pow(2,k1);
}
k1++;
}
else
{
if(x)
{
nu+=pow(2,k2);
}
k2++;
}
if(k2==11)
{
w[nu]=odl;
ile++;
for(long unsigned int i=0;i<g[nu].size();i++)
{
q.push({g[nu][i].st+odl,g[nu][i].nd});
}
while(w[q.top().nd]>-1 && q.size()>1)
{
q.pop();
}
if(ile<n)
{
for(int i=0;i<20;i++)
{
SendA(q.top().st&(1<<i));
}
for(int i=0;i<11;i++)
{
SendA(q.top().nd&(1<<i));
}
}
k1=0;k2=0;odl=0;nu=0;
}
}
#include <bits/stdc++.h>
#include "Baijan.h"
using namespace std;
#define st first
#define nd second
typedef long long ll;
int odl=0,nu=0;
int k1=0,k2=0;
int n;
vector<int>w(2000,-1);
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>q;
vector<vector<pair<int,int>>>g;
void InitB(int N, int B, std::vector<int> S, std::vector<int> T, std::vector<int> D)
{
w[0]=0;
for(int i=0;i<n;i++)
{
g.push_back({{}});
}
for(int i=0;i<B;i++)
{
g[S[i]].push_back({D[i],T[i]});
g[T[i]].push_back({D[i],S[i]});
}
for(long unsigned int i=0;i<g[0].size();i++)
{
q.push({g[0][i].st,g[0][i].nd});
}
q.push({1048575,0});
}
void ReceiveB(bool x)
{
if(k1<20)
{
if(x)
{
odl+=pow(2,k1);
}
k1++;
}
else
{
if(x)
{
nu+=pow(2,k2);
}
k2++;
}
if(k2==11)
{
while(w[q.top().nd]>-1 && q.size()>1)
{
q.pop();
}
if(odl>=q.top().st)
{
odl=q.top().st;
nu=q.top().nd;
}
w[nu]=odl;
for(long unsigned int i=0;i<g[nu].size();i++)
{
q.push({g[nu][i].st+odl,g[nu][i].nd});
}
for(int i=0;i<20;i++)
{
SendB(odl&(1<<i));
}
for(int i=0;i<11;i++)
{
SendB(nu&(1<<i));
}
k1=0;k2=0;odl=0;nu=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... |