#include <iostream>
#include <vector>
#include <algorithm>
#define DIM 530
using namespace std;
vector <int> E,v,L[DIM];
int n,i,x,y;
vector <pair<int,int> > mch;
int query (vector <int> v){
for (int i=0;i<v.size();i++)
cout<<v[i]<<" ";
cout<<endl;
int ans;
cin>>ans;
return ans;
}
void dfs (int nod, int tata){
E.push_back(nod);
for (int i=0;i<L[nod].size();i++){
int vecin = L[nod][i];
if (vecin != tata)
dfs (vecin,nod);
}
E.push_back(nod);
}
int verif (int poz1, int poz2){
v.clear();
for (int i=poz1;i<=poz2;i++)
v.push_back(E[i]);
sort (v.begin(),v.end());
v.resize(unique(v.begin(),v.end())-v.begin());
return query (v);
}
int findEgg (int n, vector <pair<int,int> > mch){
for (int i=1;i<=n;i++)
L[i].clear();
for (int i=0;i<n-1;i++){
int x = mch[i].first, y = mch[i].second;
L[x].push_back(y);
L[y].push_back(x);
}
E.clear();
dfs (1,0);
int st = 0, dr = E.size()-1;
while (st < dr){
int mid = (st+dr)>>1;
if (verif (st,mid))
dr = mid;
else{
if (verif (mid+1,dr))
st = mid+1;
}}
return E[st];
}
Compilation message
eastereggs.cpp: In function 'int query(std::vector<int>)':
eastereggs.cpp:10:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0;i<v.size();i++)
~^~~~~~~~~
eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:20:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0;i<L[nod].size();i++){
~^~~~~~~~~~~~~~
/tmp/ccOGBAFW.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/ccrUFOUT.o:eastereggs.cpp:(.text+0x30): first defined here
collect2: error: ld returned 1 exit status