#include <bits/stdc++.h>
using namespace std;
void get_preorder(vector<vector<int>> const &g, int u, int p, vector<int> &trav)
{
trav.push_back(u + 1);
for (int const &v : g[u])
if (v != p)
get_preorder(g, v, u, trav);
}
int findEgg(int n, vector<pair<int, int>> edges)
{
vector<vector<int>> g(n);
for (auto const &[u, v] : edges)
{
g[u - 1].push_back(v - 1);
g[v - 1].push_back(u - 1);
}
vector<int> preorder;
get_preorder(g, 0, -1, preorder);
size_t a = 0, b = n;
while (a < b)
{
size_t mid = (a + b) / 2;
if (query(vector<int>(preorder.begin(), preorder.begin() + mid)))
b = mid;
else
a = mid + 1;
}
return preorder[a];
}
Compilation message
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:29:13: error: 'query' was not declared in this scope
29 | if (query(vector<int>(preorder.begin(), preorder.begin() + mid)))
| ^~~~~