#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vll vector<ll>
#define vllp vector<pair<ll, ll> >
#define vi vector <int>
#define vip vector <pair <int, int> >
#define db double
#define ld long double
#define pdb pair <double, double>
#define YES cout<<"YES"
#define NO cout<<"NO"
#define nl cout<<"\n"
#define vv vector <vector <ll> >
#define pll pair <ll, ll>
#define pi pair <int, int>
#define pb push_back
#define f first
#define s second
using namespace std;
const ll mod=1e9+7;
const ll modx=998244353;
const double eps=1e-9;
const ll INF=INT_MAX;
const ll INFINF=LLONG_MAX;
const int M=512;
vi vc[M+5], nodes;
int sz[M+5], pa[M+5];
bool bad[M+5];
void dfs(int u, int par)
{
sz[u]=1;
for(auto i: vc[u])
{
if(i==par) continue;
if(bad[i]) continue;
pa[i]=u;
dfs(i, u);
sz[u]+=sz[i];
}
}
int centroid_decom(int u, int size)
{
pi p={0, 0};
for(auto i: vc[u])
{
if(i==pa[u]) continue;
p=max(p, {sz[i], i});
}
if(p.f<=(size+1)/2) return p.s;
else return centroid_decom(p.s, size);
}
void find(int u, int pa)
{
nodes.pb(u);
for(auto i: vc[u])
{
if(i==pa) continue;
find(i, u);
}
}
int findEgg(int N, vip bridges)
{
for(auto i: bridges)
{
vc[i.f].pb(i.s);
vc[i.s].pb(i.f);
}
int u=1;
while(true)
{
dfs(u, 0);
u=centroid_decom(u, N);
if(sz[u]==2)
{
nodes.pb(u);
int report=query(nodes);
if(report) return u;
else
{
for(auto i: vc[u])
{
if(!bad[i]) return i;
}
}
}
int sum=1;
vi node;
nodes.pb(u);
for(auto i: vc[u])
{
if(i==pa[u]) continue;
bad[i]=true;
sum+=sz[i];
find(i, u);
node.pb(i);
if(sum>=N/2) break;
}
int report=query(nodes);
N-=sum;
if(report)
{
for(auto i: vc[u])
{
if(!bad[i]) bad[i]^=1;
}
for(auto i: node)
{
bad[i]^=1;
}
N=sum;
}
nodes.clear();
}
}
Compilation message
eastereggs.cpp: In function 'long long int findEgg(long long int, std::vector<std::pair<long long int, long long int> >)':
eastereggs.cpp:82:15: error: 'query' was not declared in this scope
82 | int report=query(nodes);
| ^~~~~
eastereggs.cpp:104:14: error: 'query' was not declared in this scope
104 | int report=query(nodes);
| ^~~~~