#include "snowy.h"
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define ff first
#define ss second
#define pb push_back
void Save(int place, int bit);
int Ask(int place);
const int mxN = 1000;
int n;
vector<pii> edge;
void InitAnya(int N, int A[], int B[]) {
n = N;
for (int i = 0; i < n - 1; i++) {
edge.pb({A[i], B[i]});
}
}
vector<pair<int, pii>> adj[mxN]; // {node, {0/1, idx}}
int ans[mxN];
vector<int> key;
map<int, int> mp;
pii par[mxN];
int dfs(int u = 0, int pp = -1, int cur = 0) {
ans[u] = cur;
int res = 0;
for (pair<int, pii> &v : adj[u]) {
if (v.ff == pp) continue;
par[v.ff] = {u, v.ss.ss};
res = max(res, dfs(v.ff, u, cur + v.ss.ff) + 1);
}
if (res >= 10) {
key.pb(u);
res -= 10;
}
return res;
}
void Anya(int C[]) {
for (int i = 0; i < n; i++) {
adj[i].clear();
}
key.clear();
for (int i = 0; i < n - 1; i++) {
adj[edge[i].ff].pb({edge[i].ss, {C[i], i}});
adj[edge[i].ss].pb({edge[i].ff, {C[i], i}});
}
dfs();
for (int i = 0; i < n - 1; i++) {
Save(500 + i, C[i]);
}
assert(key.size() <= 50);
for (int i = 0; i < (int)(key.size()); i++) {
for (int j = 0; j < 10; j++) {
Save(i * 10 + j, bool(ans[key[i]] & (1 << j)));
}
}
}
void InitBoris(int N, int A[], int B[]) {
n = N;
for (int i = 0; i < n - 1; i++) {
adj[A[i]].pb({B[i], {0, i}});
adj[B[i]].pb({A[i], {0, i}});
}
dfs();
mp[0] = -1;
for (int i = 0; i < (int)(key.size()); i++) {
mp[key[i]] = i;
}
}
int Boris(int city) {
int ans = 0;
while (mp.find(city) == mp.end()) {
ans += Ask(500 + par[city].ss);
city = par[city].ff;
}
if (city) {
for (int i = 0; i < 10; i++) {
ans += (Ask(mp[city] * 10 + i) << i);
}
}
return ans;
}
Compilation message
Anya.cpp:1:10: fatal error: snowy.h: No such file or directory
1 | #include "snowy.h"
| ^~~~~~~~~
compilation terminated.
/usr/bin/ld: /tmp/cc918vfc.o: in function `main':
grader_boris.cpp:(.text.startup+0x17d): undefined reference to `InitBoris(int, int*, int*)'
/usr/bin/ld: grader_boris.cpp:(.text.startup+0x2ab): undefined reference to `Boris(int)'
collect2: error: ld returned 1 exit status