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;
using ar = array<int,2>;
using vi = vector<int>;
#define pb push_back
namespace {
const int mxN = (int)2e3+10;
int n,dis[mxN];
vector<ar> adj[mxN];
void dijkstra(){
priority_queue<ar,vector<ar>,greater<ar>> pq;
memset(dis,63,sizeof(dis));
pq.push({0,0}); dis[0]=0;
while(!pq.empty()){
auto [D,a] = pq.top(); pq.pop();
if(D!=dis[a]) continue;
for(auto [b,w] : adj[a])
if(dis[b]>dis[a]+w)
dis[b]=dis[a]+w,pq.push({dis[b],b});
}
}
void Send(int x, int sz){
for(int i = 0; i < sz; i++)
SendA((x>>i)&1);
}
}
void InitA(int N, int A, vi U, vi V, vi C) {
n = N; fill(dis,dis+mxN,0);
for (int i = 0; i < A; ++i) {
adj[U[i]].pb({V[i],C[i]});
adj[V[i]].pb({U[i],C[i]});
}
}
int u=0, v=0, c=0, xd=0;
void ReceiveA(bool x) {
if(xd<11) u|=(1<<xd)*x;
else if(xd<22) v|=(1<<(xd-11))*x;
else c|=(1<<(xd-22))*x;
xd++;
if(xd==31){
adj[u].pb({v,c}),adj[v].pb({u,c});
xd = u = v = c = 0;
}
}
vi Answer() {
dijkstra();
vi ans(n,0);
for(int k = 1; k < n; ++k)
ans[k] = dis[k];
return ans;
}
#include "Baijan.h"
#include <bits/stdc++.h>
using namespace std;
using ar = array<int,2>;
using vi = vector<int>;
#define pb push_back
namespace {
const int mxN = (int)2e3+10;
int n,dis[mxN];
vector<ar> adj[mxN];
void dijkstra(){
priority_queue<ar,vector<ar>,greater<ar>> pq;
memset(dis,63,sizeof(dis));
pq.push({0,0}); dis[0]=0;
while(!pq.empty()){
auto [D,a] = pq.top(); pq.pop();
if(D!=dis[a]) continue;
for(auto [b,w] : adj[a])
if(dis[b]>dis[a]+w)
dis[b]=dis[a]+w,pq.push({dis[b],b});
}
}
void Send(int x, int sz){
for(int i = 0; i < sz; i++)
SendB((x>>i)&1);
}
}
void InitB(int N, int B, vi U, vi V, vi C) {
n = N; fill(dis,dis+mxN,0);
for (int i = 0; i < B; ++i) {
adj[U[i]].pb({V[i],C[i]});
adj[V[i]].pb({U[i],C[i]});
Send(U[i],11), Send(V[i],11), Send(C[i],9);
}
}
void ReceiveB(bool y) {
}
Compilation message (stderr)
Azer.cpp:24:7: warning: 'void {anonymous}::Send(int, int)' defined but not used [-Wunused-function]
24 | void Send(int x, int sz){
| ^~~~
Baijan.cpp:12:7: warning: 'void {anonymous}::dijkstra()' defined but not used [-Wunused-function]
12 | void dijkstra(){
| ^~~~~~~~
# | 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... |