#include <cstdio>
#include <vector>
using namespace std;
int poz;
void euler (int nod ,int tata, vector <pair <int,int> > v , vector <int> &eul ){
int x,y;
eul.push_back(nod);
for (int i = 0 ; i < v.size() ; i++){
x = v[i].first;
y = v[i].second;
if (x == nod && y!=tata){
euler (y,nod,v,eul);
eul.push_back(nod);
}
else if (y == nod && x != tata){
euler (x,nod,v,eul);
eul.push_back(nod);
}
}
}
int findEgg (int n , vector <pair <int,int> > v){
int st,dr,mid,sol;
vector <int> eul,islands;
euler(1,0,v,eul); /// eul e un vector cu parc euler , dim 2*n
st = 0;
dr = 2*n-2;
while (st<dr){
mid = (st + dr)/2;
/// iei de la st la mid
islands.clear();
for (int i=st;i<=mid;i++)
islands.push_back(eul[i]);
sol = query(islands);
if (sol == 0)
st = mid + 1;
else dr = mid;
}
return eul[st];
}
Compilation message
eastereggs.cpp: In function 'void euler(int, int, std::vector<std::pair<int, int> >, std::vector<int>&)':
eastereggs.cpp:9:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0 ; i < v.size() ; i++){
~~^~~~~~~~~~
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:35:15: error: 'query' was not declared in this scope
sol = query(islands);
^~~~~