#include "Anyalib.h"
#include <algorithm>
using namespace std;
const static int t = 11;
typedef pair<int, int> pii;
const static int MAXN = 500;
static int n;
static vector<pii> edge[MAXN];
static int s[MAXN], e[MAXN];
static pii close[MAXN];
static void dfs1(int x, int p, pii cl) {
if (cl.first > t) {
close[x] = pii(0, x);
cl = pii(0, x);
}
++cl.first;
for (pii i : edge[x]) {
if (i.second == p) continue;
dfs1(i.second, x, cl);
pii tp = close[i.second];
tp.first += 2;
cl = min(cl, tp);
}
}
static int dist[MAXN];
static int par[MAXN];
static void dfs2(int x, int p, int d, int C[]) {
dist[x] = d;
for (pii i : edge[x]) {
if (i.second == p) continue;
par[i.second] = C[i.first];
dfs2(i.second, x, d + C[i.first], C);
}
}
void InitAnya(int N , int A[] , int B[]) {
n = N;
for (int i = 0; i < n - 1; ++i) {
edge[A[i]].emplace_back(i, B[i]);
edge[B[i]].emplace_back(i, A[i]);
}
dfs1(0, -1, pii(20, -1));
int p = 0;
for (int i = 0; i < n; ++i) {
s[i] = p;
p = p + (close[i].first ? 1 : 10);
e[i] = p - 1;
}
}
void Anya(int C[]) {
dfs2(0, -1, 0, C);
for (int i = 0; i < n; ++i) {
Save(s[i], par[i]);
for (int j = s[i] + 1; j <= e[i]; ++j) {
Save(j, dist[i] & 1);
dist[i] >>= 1;
}
}
}
#include "Borislib.h"
#include <algorithm>
using namespace std;
const static int t = 11;
typedef pair<int, int> pii;
const static int MAXN = 500;
static int n;
static vector<pii> edge[MAXN];
static int s[MAXN], e[MAXN];
static pii close[MAXN];
static int par[MAXN];
static int dep[MAXN];
static void dfs1(int x, int p, pii cl) {
par[x] = p;
if (cl.first > t) {
close[x] = pii(0, x);
cl = pii(0, x);
}
++cl.first;
for (pii i : edge[x]) {
if (i.second == p) continue;
dep[i.second] = dep[x] + 1;
dfs1(i.second, x, cl);
pii tp = close[i.second];
tp.first += 2;
cl = min(cl, tp);
}
}
void InitBoris(int N , int A[] , int B[]) {
n = N;
for (int i = 0; i < n - 1; ++i) {
edge[A[i]].emplace_back(i, B[i]);
edge[B[i]].emplace_back(i, A[i]);
}
dfs1(0, -1, pii(20, -1));
int p = 0;
for (int i = 0; i < n; ++i) {
s[i] = p;
p = p + (close[i].first ? 1 : 10);
e[i] = p - 1;
}
}
int Boris(int x) {
int y = close[x].second;
int ret = 0;
for (int i = e[y]; i > s[y]; --i) {
ret <<= 1;
ret += Ask(i);
}
while (dep[x] < dep[y]) {
ret -= Ask(s[y]);
y = par[y];
}
while (dep[x] > dep[y]) {
ret += Ask(s[x]);
x = par[x];
}
while (x != y) {
ret += Ask(s[x]) - Ask(s[y]);
x = par[x];
y = par[y];
}
return ret;
}
Compilation message
Anya.cpp:11:8: error: 'vector' does not name a type; did you mean 'qecvt_r'?
static vector<pii> edge[MAXN];
^~~~~~
qecvt_r
Anya.cpp: In function 'void dfs1(int, int, pii)':
Anya.cpp:20:18: error: 'edge' was not declared in this scope
for (pii i : edge[x]) {
^~~~
Anya.cpp: In function 'void dfs2(int, int, int, int*)':
Anya.cpp:33:18: error: 'edge' was not declared in this scope
for (pii i : edge[x]) {
^~~~
Anya.cpp: In function 'void InitAnya(int, int*, int*)':
Anya.cpp:43:9: error: 'edge' was not declared in this scope
edge[A[i]].emplace_back(i, B[i]);
^~~~
Boris.cpp:11:8: error: 'vector' does not name a type; did you mean 'qecvt_r'?
static vector<pii> edge[MAXN];
^~~~~~
qecvt_r
Boris.cpp: In function 'void dfs1(int, int, pii)':
Boris.cpp:23:18: error: 'edge' was not declared in this scope
for (pii i : edge[x]) {
^~~~
Boris.cpp: In function 'void InitBoris(int, int*, int*)':
Boris.cpp:36:9: error: 'edge' was not declared in this scope
edge[A[i]].emplace_back(i, B[i]);
^~~~