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 "Azer.h"
#include<bits/stdc++.h>
using namespace std;
#define S second
#define F first
namespace {
const int mxn=5e5+5;
int cur=0,bit=0,n;
vector<pair<int,int>>adj[mxn];
vector<int>dis(mxn);
int prev=0;
vector<bool>vis(mxn);
bool first=1;
pair<int,int>mn={(1<<9)-1,(1<<9)-1};
void send(int a,int b){
b--;
for(;b>=0;b--){
SendA(a>>b&1);
}
}
void gmn(){
dis[mn.S]=prev+mn.F;
prev=dis[mn.S];
vis[mn.S]=1;
for(auto [u,d]:adj[mn.S]){
dis[u]=min(dis[u],dis[mn.S]+d);
}
for(int i=0;i<n;i++){
if(vis[i])continue;
mn=min(mn,{dis[i]-prev,i});
}
}
void gdis(){
if(cur==(1<<9)-1){
send(mn.S,11);
gmn();
}
else{
mn.F=cur;
first=0;
}
cur=bit=0;
}
void gid(){
mn.S=cur;
gmn();
cur=bit=0;
first=1;
}
} // namespace
void InitA(int N, int A, std::vector<int> U, std::vector<int> V,std::vector<int> C) {
for(int i=0;i<A;i++){
adj[V[i]].push_back({U[i],C[i]});
adj[U[i]].push_back({V[i],C[i]});
}
dis[0]=0;
vis[0]=1;
for(int i=1;i<=N;i++){
dis[i]=1e18;
vis[i]=0;
}
int v=0;
for(auto [u,d]:adj[v]){
dis[u]=min(dis[u],dis[v]+d);
mn=min(mn,{dis[u],u});
}
send(mn.F,9);
}
void ReceiveA(bool x) {
cur=cur*2+x;
bit++;
if(bit==9 and first){
gdis();
}
else if(bit==11){
gid();
}
}
std::vector<int> Answer() {
return dis;
}
#include "Baijan.h"
#include<bits/stdc++.h>
using namespace std;
#define S second
#define F first
namespace {
const int mxn=5e5+5;
int cur=0,bit=0,n;
vector<pair<int,int>>adj[mxn];
vector<int>dis(mxn);
int prev=0;
vector<bool>vis(mxn);
bool first=1;
pair<int,int>mn={(1<<9)-1,(1<<9)-1};
void send(int a,int b){
b--;
for(;b>=0;b--){
SendB(a>>b&1);
}
}
void gmn(){
dis[mn.S]=prev+mn.F;
prev=dis[mn.S];
vis[mn.S]=1;
for(auto [u,d]:adj[mn.S]){
dis[u]=min(dis[u],dis[mn.S]+d);
}
for(int i=0;i<n;i++){
if(vis[i])continue;
mn=min(mn,{dis[i]-prev,i});
}
}
void gdis(){
if(mn.F>cur){
mn.F=cur;
send((1<<9)-1,9);
}
else{
send(mn.F,9);
send(mn.S,11);
gmn();
first=0;
}
cur=bit=0;
}
void gid(){
mn.S=cur;
gmn();
cur=bit=0;
first=1;
}
} // namespace
void InitB(int N, int B, std::vector<int> U, std::vector<int> V,std::vector<int> C) {
for(int i=0;i<B;i++){
adj[V[i]].push_back({U[i],C[i]});
adj[U[i]].push_back({V[i],C[i]});
}
n=N;
dis[0]=0;
vis[0]=1;
for(int i=1;i<=N;i++){
dis[i]=1e18;
vis[i]=0;
}
int v=0;
for(auto [u,d]:adj[v]){
dis[u]=min(dis[u],dis[v]+d);
mn=min(mn,{dis[u],u});
}
}
void ReceiveB(bool x) {
cur=cur*2+x;
bit++;
if(bit==9 and first){
gdis();
}
else if(bit==11){
gid();
}
}
Compilation message (stderr)
Azer.cpp: In function 'void InitA(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
Azer.cpp:59:16: warning: overflow in conversion from 'double' to '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} changes value from '1.0e+18' to '2147483647' [-Woverflow]
59 | dis[i]=1e18;
| ^~~~
Baijan.cpp: In function 'void InitB(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
Baijan.cpp:62:16: warning: overflow in conversion from 'double' to '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} changes value from '1.0e+18' to '2147483647' [-Woverflow]
62 | dis[i]=1e18;
| ^~~~
# | 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... |