#include <iostream>
#include <vector>
#include "Azer.h"
using namespace std;
vector<pair<int, int>> g[2005], gg[2005];
int n, dd[2005], f[2005], cc = 0, hh = 9, d = 0, y, ca = 0;
pair<int, pair<int, int>> trya() {
int mi = 2e9, h, ma = 0;
for (int i = 0; i < n; i++) {
if (dd[i] == 1) {
ma = max(ma, f[i]);
}
else {
if (mi > f[i]) {
mi = f[i];
h = i;
}
}
}
return {mi - ma, {ma, h}};
}
void send(int x, int y) {
if (ca == n && y == 9) return;
if (y == 9) x = min(x, 511);
for (int i = 0; i < y; i++) {
if (x & (1 << i)) SendA(1);
else SendA(0);
}
}
void InitA(int N, int a, vector<int> u, vector<int> v, vector<int> c) {
for (int i = 0; i < u.size(); i++) {
g[u[i]].push_back({v[i], c[i]});
g[v[i]].push_back({u[i], c[i]});
}
n = N;
f[0] = 0;
for (int i = 1; i < n; i++) f[i] = 1e9;
auto h = trya();
send(h.first, 9);
hh = 9;
}
void update(int d, int x) {
ca++;
f[d] = x;
for (auto w : g[d]) {
f[w.first] = min(f[d] + w.second, f[w.first]);
}
}
void ReceiveA(bool x) {
if (x == 1) d |= (1 << cc);
cc++;
if (cc == hh) {
if (hh == 11) {
auto h = trya();
dd[d] = 1;
update(d, h.second.first + y);
hh = 9;
h = trya();
send(h.first, 9);
}
else {
auto h = trya();
if (h.first <= d) {
send(h.second.second, 11);
update(h.second.second, h.second.first + h.first);
dd[h.second.second] = 1;
h = trya();
send(h.first, 9);
}
else {
hh = 11;
y = d;
}
}
cc = d = 0;
}
}
vector<int> Answer() {
vector<int> v;
for (int i = 0; i < n; i++) v.push_back(f[i]);
return v;
}
#include <iostream>
#include <vector>
#include "Baijan.h"
using namespace std;
vector<pair<int, int>> gg[2005];
int n, dda[2005], fa[2005], cca = 0, hha = 9, da = 0, ya, caa = 0;
pair<int, pair<int, int>> trya2() {
int mi = 2e9, h, ma = 0;
for (int i = 0; i < n; i++) {
if (dda[i] == 1) {
ma = max(ma, fa[i]);
}
else {
if (mi > fa[i]) {
mi = fa[i];
h = i;
}
}
}
return {mi - ma, {ma, h}};
}
void send2(int x, int y) {
if (caa == n && y == 9) return;
if (y == 9) x = min(x, 511);
for (int i = 0; i < y; i++) {
if (x & (1 << i)) SendB(1);
else SendB(0);
}
}
void InitB(int N, int a, vector<int> u, vector<int> v, vector<int> c) {
for (int i = 0; i < u.size(); i++) {
gg[u[i]].push_back({v[i], c[i]});
gg[v[i]].push_back({u[i], c[i]});
}
n = N;
fa[0] = 0;
for (int i = 1; i < n; i++) fa[i] = 1e9;
auto h = trya2();
send2(h.first, 9);
hha = 9;
}
void update2(int d, int x) {
caa++;
fa[d] = x;
for (auto w : gg[d]) {
fa[w.first] = min(fa[d] + w.second, fa[w.first]);
}
}
void ReceiveB(bool x) {
if (x == 1) da |= (1 << cca);
cca++;
if (cca == hha) {
if (hha == 11) {
auto h = trya2();
dda[da] = 1;
update2(da, h.second.first + ya);
hha = 9;
h = trya2();
send2(h.first, 9);
}
else {
auto h = trya2();
if (h.first < da) {
send2(h.second.second, 11);
update2(h.second.second, h.second.first + h.first);
dda[h.second.second] = 1;
h = trya2();
send2(h.first, 9);
}
else {
hha = 11;
ya = da;
}
}
cca = da = 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... |