이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "Azer.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
int n;
vector<int> dist;
vector<bool> was;
vector<vector<pair<int, int>>> g;
int cd = 0;
void update(int i) {
was[i] = true;
cd = dist[i];
for (auto& p : g[i]) {
int j = p.first;
int w = p.second;
if (dist[j] > dist[i] + w) {
dist[j] = dist[i] + w;
}
}
}
int idx = -1;
int s;
void send() {
for (int i = 0; i < n; i++) {
if (was[i]) {
continue;
}
if (idx == -1 || dist[i] < dist[idx]) {
idx = i;
}
}
if (idx == -1) {
return;
}
s = dist[idx] - cd;
for (int i = 8; i >= 0; i--) {
SendA(s >> i & 1);
}
}
int f = 0;
int cnt = 0;
int state = 1;
int tmp = 0;
}
void InitA(int N, int a, vector<int> u, vector<int> v, vector<int> c) {
n = N;
dist = vector<int>(n, 1e9);
dist[0] = 0;
g.resize(n);
was.resize(n);
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]);
}
update(0);
send();
}
void ReceiveA(bool x) {
f = 2 * f + x;
if (state == 1) {
if (cnt == 9) {
if (s <= f) {
for (int i = 10; i >= 0; i--) {
SendA(idx >> i & 1);
}
cnt = 0;
f = 0;
update(s);
send();
} else {
tmp = f;
f = 0;
state = 2;
cnt = 0;
}
}
} else if (state == 2) {
if (cnt == 11) {
dist[f] = s + tmp;
update(f);
send();
cnt = 0;
f = 0;
}
}
}
vector<int> Answer() {
vector<int> ans;
for (int i = 0; i < n; i++) {
ans.push_back(dist[i]);
}
return ans;
}
#include "Baijan.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
int n;
vector<int> dist;
vector<bool> was;
vector<vector<pair<int, int>>> g;
int cd = 0;
void update(int i) {
was[i] = true;
cd = dist[i];
for (auto& p : g[i]) {
int j = p.first;
int w = p.second;
if (dist[j] > dist[i] + w) {
dist[j] = dist[i] + w;
}
}
}
int idx = -1;
int s;
void send() {
for (int i = 0; i < n; i++) {
if (was[i]) {
continue;
}
if (idx == -1 || dist[i] < dist[idx]) {
idx = i;
}
}
if (idx == -1) {
return;
}
s = dist[idx] - cd;
for (int i = 8; i >= 0; i--) {
SendB(s >> i & 1);
}
}
int f = 0;
int cnt = 0;
int state = 1;
int tmp = 0;
}
void InitB(int N, int a, vector<int> u, vector<int> v, vector<int> c) {
n = N;
dist = vector<int>(n, 1e9);
dist[0] = 0;
g.resize(n);
was.resize(n);
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]);
}
update(0);
send();
}
void ReceiveB(bool x) {
f = 2 * f + x;
if (state == 1) {
if (cnt == 9) {
if (s < f) {
assert(idx != -1);
for (int i = 10; i >= 0; i--) {
SendB(idx >> i & 1);
}
cnt = 0;
f = 0;
update(s);
send();
} else {
tmp = f;
f = 0;
state = 2;
cnt = 0;
}
}
} else if (state == 2) {
if (cnt == 11) {
dist[f] = s + tmp;
update(f);
send();
cnt = 0;
f = 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... |