#include <bits/stdc++.h>
using namespace std;
int query(vector < int > islands)
{
cout << "? ";
for (int x : islands)
cout << x << ' ';
cout << '\n';
int ans;
cin >> ans;
return ans;
}
vector<int>v[513];
vector<int>order;
void dfs (int x, int par)
{
order.push_back(x);
for (int i : v[x])
{
if (i == par)
continue;
dfs(i, x);
}
}
int findEgg(int N, vector < pair < int, int > > bridges)
{
for (pair<int, int>p : bridges)
{
v[p.first].push_back(p.second);
v[p.second].push_back(p.first);
}
dfs(1, -1);
int l=1, r=N;
while (l < r)
{
int mid = (l + r) / 2;
vector<int>curr;
for (int i=0; i<mid; i++)
curr.push_back(order[i]);
if (query(curr))
r = mid;
else
l = mid + 1;
}
return order[r-1];
}
int main()
{
int N = 5;
vector<pair<int, int>>bridges = {{1, 2}, {1, 3}, {2, 4}, {4, 5}};
cout << findEgg(N, bridges);
return 0;
}
Compilation message
/usr/bin/ld: /tmp/cczd6XtK.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/cc7neFzM.o:eastereggs.cpp:(.text+0x50): first defined here
/usr/bin/ld: /tmp/cczd6XtK.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc7neFzM.o:eastereggs.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status