#include "Azer.h"
#include <bits/stdc++.h>
#define ar array
using namespace std;
const int MXN = 2005;
static int res[MXN], a[MXN][MXN];
static set <ar <int, 2>> st[MXN];
static vector <int> com;
static int cnt = 0, n;
static void add(int x, int d) {
vector <int> c(n);
for (int i : com) {
c[i] = 1;
if (a[i][x]) {
st[i].erase({res[i] + a[i][x], x});
}
}
com.push_back(x);
c[x] = 1;
res[x] = d;
for (int i = 0; i < n; i++) {
if (!c[i] && a[x][i]) {
st[x].insert({res[x] + a[x][i], i});
}
}
}
static int pra = 0, prb = 0, st9 = 9, st11 = 11, db = 0, d, x;
static void go() {
ar <int, 2> cur = {pra + 505, n + 1};
for (int i : com)
cur = min(cur, *st[i].begin());
x = cur[1];
d = cur[0] - pra;
st9 = st11 = 0;
db = 0;
for (int i = 0; i < 9; i++)
SendA((d >> i) & 1);
}
void InitA(int N, int A, vector<int> U, vector<int> V, vector<int> C) {
n = N;
res[0] = 0;
for (int i = 1; i < n; i++)
res[i] = n + 1;
for (int i = 0; i < A; i++)
a[U[i]][V[i]] = a[V[i]][U[i]] = C[i];
add(0, 0);
go();
}
void ReceiveA(bool bt) {
if (st9 < 9) {
db |= bt << st9;
st9++;
if (st9 == 9) {
if (min(db, d) > 500)
return;
db += prb;
d += pra;
if (d > db) {
for (int i = 0; i < 11; i++)
SendA((x >> i) & 1);
pra = d;
add(x, d);
go();
} else {
x = 0;
}
}
} else {
if (st11 < 11) {
x |= bt << st11;
st11++;
}
if (st11 == 11) {
prb = db;
add(x, db);
go();
}
}
}
vector <int> Answer() {
vector<int> ans(n, n + 1);
for (int i = 0; i < n; i++)
ans[i] = res[i];
return ans;
}
#include "Baijan.h"
#include <bits/stdc++.h>
#define ar array
using namespace std;
const int MXN = 2005;
int res[MXN], b[MXN][MXN];
set <ar <int, 2>> st[MXN];
vector <int> com;
int cnt = 0, n;
void add(int x, int d) {
vector <int> c(n);
for (int i : com) {
c[i] = 1;
if (b[i][x]) {
st[i].erase({res[i] + b[i][x], x});
}
}
com.push_back(x);
c[x] = 1;
res[x] = d;
for (int i = 0; i < n; i++) {
if (!c[i] && b[x][i]) {
st[x].insert({res[x] + b[x][i], i});
}
}
}
int pra = 0, prb = 0, st9 = 9, st11 = 11, da = 0, d, x;
void go() {
ar <int, 2> cur = {prb + 505, n + 1};
for (int i : com)
cur = min(cur, *st[i].begin());
x = cur[1];
d = cur[0] - prb;
st9 = st11 = 0;
da = 0;
for (int i = 0; i < 9; i++)
SendB((d >> i) & 1);
}
void InitB(int N, int B, vector<int> S, vector<int> T, vector<int> D) {
int pra = 0, prb = 0;
n = N;
for (int i = 0; i < n; i++)
res[i] = n + 1;
for (int i = 0; i < B; i++)
b[S[i]][T[i]] = b[T[i]][S[i]] = D[i];
add(0, 0);
go();
}
void ReceiveB(bool bt) {
if (st9 < 9) {
da |= bt << st9;
st9++;
if (st9 == 9) {
if (min(da, d) > 500)
return;
da += pra;
d += prb;
if (d > da) {
for (int i = 0; i < 11; i++)
SendB((x >> i) & 1);
prb = d;
add(x, d);
go();
} else {
x = 0;
}
}
} else {
if (st11 < 11) {
x |= bt << st11;
st11++;
}
if (st11 == 11) {
pra = da;
add(x, da);
go();
}
}
}
# | 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... |