#include <bits/stdc++.h>
#include "grader.h"
#include "grader.cpp"
using namespace std;
#define pb push_back
int ans = 0;
vector<int> g[200004];
int us[200005], m, ctr;
int dcnt(int pos, int pre){
int s = 1;
for(auto to:g[pos]){
if(us[to] || to == pre)continue;
s+=dcnt(to, pos);
}
return s;
}
int dct(int pos, int pre){
bool ok = 1;
int s = 1;
for(auto to:g[pos]){
if(us[to] || to == pre)continue;
int sn = 0;
sn = dcnt(to, pos);
if(sn > m/2)ok = 0;
s+=sn;
}
if(s < m/2)ok = 0;
if(ok)ctr = pos;
return s;
}
vector<int> re;
void dfs(int pos, int pre){
re.pb(pos);
for(int to:g[pos]){
if(us[to] || to == pre)continue;
dfs(to, pos);
}
}
void ctrdec(int pos){
m = dcnt(pos, -1);
m = dct(pos, -1);
us[ctr] = 1;
ans = ctr;
for(auto to:g[ctr]){
re.clear();
dfs(to, -1);
if(!query(re))continue;
ctrdec(to);
}
}
int findEgg (int n, vector < pair < int, int > > way)
{
for(auto [u, v]: way){
g[u].pb(v);
g[v].pb(u);
}
ctrdec(1);
return ans;
}
Compilation message
/usr/bin/ld: /tmp/ccajmAjJ.o: in function `query(std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0x0): multiple definition of `query(std::vector<int, std::allocator<int> >)'; /tmp/ccg9Q59I.o:eastereggs.cpp:(.text+0x50): first defined here
/usr/bin/ld: /tmp/ccajmAjJ.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccg9Q59I.o:eastereggs.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status