#include <iostream> #include <vector> #include <cstring> #include <bitset> #include <set> #include <deque> #include <queue> #include <iomanip> #include <map> #include <algorithm> #include <cmath> #include <stack> #include <sstream> #include <functional> #include <utility> #include <cstdio> using namespace std; #define mp make_pair #define pb push_back #define ff first #define ss second typedef pair<int,int> pii; typedef long long ll; int main(){ ios_base::sync_with_stdio(false); int n, k; cin>>n>>k; //read the number of stories and eggs int l,r,x; l = 1,r = n; string response; while(response != "exit") { x = (l+r)/2; cout << "query " << x << "\n"; //can also use endl for newline cout.flush(); cin >> response; if(response == "broke") k--,r = x-1; else if(response == "survived") k--, l = x; if(l == r - 1){ cout << "query " << r << "\n"; //can also use endl for newline cout.flush(); cin >> response; if(response == "survived") x = r; else x = l; //in case you've found the answer cout << "answer " << x << "\n"; cout.flush(); cin >> response; } } }