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>
#define iii tuple<int, int, int>
#define pii pair<int, int>
#define x first
#define y second
using namespace std;
namespace {
int N, A;
vector<pii> g[2000];
vector<int> d;
int step, val;
int ns, nid;
int u, v, w;
void dijkstra() {
priority_queue<pii, vector<pii>, greater<pii> > Q;
Q.emplace(d[0] = 0, 0);
while(!Q.empty()) {
auto u = Q.top(); Q.pop();
if(u.x != d[u.y]) continue;
for(auto v : g[u.y]) if(d[v.x] > d[u.y] + v.y)
Q.emplace(d[v.x] = d[u.y] + v.y, v.x);
}
}
}
void InitA(int N, int A, vector<int> U, vector<int> V, vector<int> C) {
SendA(A ? true : false);
::N = N, ::A = A;
d.resize(N, (1 << 20) - 1);
for(int i = 0; i < A; ++i) {
g[U[i]].emplace_back(V[i], C[i]);
g[V[i]].emplace_back(U[i], C[i]);
}
}
void ReceiveA(bool x) {
if(step <= 18) {
if(x) val |= 1 << step;
step++;
} else {
if(A) {
if(ns < 12) { if(x) u |= 1 << ns; }
else if(ns < 24) { if(x) v |= 1 << (ns-12); }
else { if(x) w |= 1 << (ns-24); }
if(++ns == 33) {
nid++;
g[u].emplace_back(v, w), g[v].emplace_back(u, w);
u = v = w = ns = 0;
}
if(nid == val) dijkstra();
} else {
if(x) w |= 1 << ns;
if(++ns == 20) {
d[nid++] = w;
w = ns = 0;
}
}
}
}
vector<int> Answer() {
return d;
}
#include "Baijan.h"
#include <bits/stdc++.h>
#define iii tuple<int, int, int>
#define pii pair<int, int>
#define x first
#define y second
using namespace std;
namespace {
int N;
int count;
int val;
int step, nid, ns;
int u, v, w;
vector<iii> E;
vector<pii> g[2000];
vector<int> d;
void dijkstra() {
priority_queue<pii, vector<pii>, greater<pii> > Q;
Q.emplace(d[0] = 0, 0);
while(!Q.empty()) {
auto u = Q.top(); Q.pop();
if(u.x != d[u.y]) continue;
for(auto v : g[u.y]) if(d[v.x] > d[u.y] + v.y)
Q.emplace(d[v.x] = d[u.y] + v.y, v.x);
}
}
}
void InitB(int N, int B, vector<int> S, vector<int> T, vector<int> D) {
for(int i = 0; i <= 18; ++i) SendB(B >> i & 1);
::N = N;
d.resize(N, (1<<20) - 1);
for(int i = 0; i < B; ++i) {
E.emplace_back(S[i], T[i], D[i]);
g[S[i]].emplace_back(T[i], D[i]);
g[T[i]].emplace_back(S[i], D[i]);
}
}
void ReceiveB(bool y) {
if(y) {
for(auto x : E) {
int u, v, w; tie(u, v, w) = x;
for(int i = 0; i < 12; ++i) SendB(u >> i & 1);
for(int i = 0; i < 12; ++i) SendB(v >> i & 1);
for(int i = 0; i < 9; ++i) SendB(w >> i & 1);
}
} else {
dijkstra();
for(int i = 0; i < N; ++i) {
for(int j = 0; j < 20; ++j) SendB(d[i] >> j & 1);
}
}
}
Compilation message (stderr)
Baijan.cpp:14:13: warning: '{anonymous}::w' defined but not used [-Wunused-variable]
int u, v, w;
^
Baijan.cpp:14:10: warning: '{anonymous}::v' defined but not used [-Wunused-variable]
int u, v, w;
^
Baijan.cpp:14:7: warning: '{anonymous}::u' defined but not used [-Wunused-variable]
int u, v, w;
^
Baijan.cpp:13:18: warning: '{anonymous}::ns' defined but not used [-Wunused-variable]
int step, nid, ns;
^~
Baijan.cpp:13:13: warning: '{anonymous}::nid' defined but not used [-Wunused-variable]
int step, nid, ns;
^~~
Baijan.cpp:13:7: warning: '{anonymous}::step' defined but not used [-Wunused-variable]
int step, nid, ns;
^~~~
Baijan.cpp:12:7: warning: '{anonymous}::val' defined but not used [-Wunused-variable]
int val;
^~~
Baijan.cpp:11:7: warning: '{anonymous}::count' defined but not used [-Wunused-variable]
int count;
^~~~~
# | 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... |