#include "Azer.h"
#include<bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
#define f first
#define s second
#define eb emplace_back
#define sz(x) (int)x.size()
namespace {
vector<pii> adj[2005];
priority_queue<pii,vector<pii>,greater<pii>> pq;
int d[2005],n,m0,cnt,v0,w0,prv;
vector<int> tmp;
void send(bool x){ return SendA(x); }
void send(int x,int m){ while(m--) send(x&1), x>>=1; }
void send(pii x){
send(x.s,11);
send(min(x.f-prv,511),9);
}
void play(){
auto [w,u]=pq.top(); pq.pop();
if(u==n+1) return;
if(d[u]!=w) return play();
for(auto &[v,vw]:adj[u]) if(d[v]>w+vw) pq.emplace(d[v]=w+vw,v);
while(!pq.empty() && pq.top().s!=n+1 && d[pq.top().s]!=pq.top().f) pq.pop();
prv=w;
send(pq.top());
}
} // namespace
void InitA(int N, int A, std::vector<int> U, std::vector<int> V, std::vector<int> C) {
n=N;
for(int i=0;i<A;++i) adj[U[i]].eb(V[i],C[i]), adj[V[i]].eb(U[i],C[i]);
m0=cnt=0;
fill(d,d+N,int(1e6));
pq.emplace(int(1e6)+1,N+1);
pq.emplace(d[0]=0,0);
play();
}
void ReceiveA(bool x) {
if(cnt<11) m0 |= x<<cnt;
else m0 |= x<<cnt-11;
++cnt;
if(cnt==11) v0=m0, m0=0;
else if(cnt==20){
w0=(m0==511 ? int(1e6)+1 : m0+prv);
m0=cnt=0;
if(v0!=n+1 && d[v0]>w0) pq.emplace(d[v0]=w0,v0);
play();
}
}
std::vector<int> Answer() {
vector<int> ans(n);
for(int i=0;i<n;++i) ans[i]=d[i];
return ans;
}
#include "Baijan.h"
#include<bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
#define eb emplace_back
#define sz(x) (int)x.size()
#define f first
#define s second
namespace {
vector<pii> adj[2005];
priority_queue<pii,vector<pii>,greater<pii>> pq;
int d[2005],n,m0,cnt,v0,w0,prv;
vector<int> tmp;
void send(bool x){ return SendB(x); }
void send(int x,int m){ while(m--) send(x&1), x>>=1; }
void send(pii x){
send(x.s,11);
send(min(x.f-prv,511),9);
}
void play(){
auto [w,u]=pq.top(); pq.pop();
if(u==n+1) return;
if(d[u]!=w) return play();
for(auto &[v,vw]:adj[u]) if(d[v]>w+vw) pq.emplace(d[v]=w+vw,v);
while(!pq.empty() && pq.top().s!=n+1 && d[pq.top().s]!=pq.top().f) pq.pop();
prv=w;
send(pq.top());
}
} // namespace
void InitB(int N, int A, std::vector<int> U, std::vector<int> V, std::vector<int> C) {
n=N;
for(int i=0;i<A;++i) adj[U[i]].eb(V[i],C[i]), adj[V[i]].eb(U[i],C[i]);
m0=cnt=0;
fill(d,d+N,int(1e6));
pq.emplace(int(1e6)+1,N+1);
pq.emplace(d[0]=0,0);
play();
}
void ReceiveB(bool x) {
if(cnt<11) m0 |= x<<cnt;
else m0 |= x<<cnt-11;
++cnt;
if(cnt==11) v0=m0, m0=0;
else if(cnt==20){
w0=(m0==511 ? int(1e6)+1 : m0+prv);
m0=cnt=0;
if(v0!=n+1 && d[v0]>w0) pq.emplace(d[v0]=w0,v0);
play();
}
}
# | 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... |