#include #include using namespace std; int main() { int inc, sf, mij, n, k; char response[10]=""; cin>>n>>k; //scanf("%d%d",&n,&k); sf=n; inc=0; while(strcmp(response,"exit")) { if(sf-inc==1) { cout << "answer " << inc+1 << "\n"; cout.flush(); cin >> response; //printf("answer %d\n",inc+1); //fflush(stdout); //scanf("%s",response); } else { mij=(sf+inc)/2; cout << "query " << mij << "\n"; cout.flush(); cin >> response; //printf("query %d\n",mij); //fflush(stdout); //scanf("%s",response); if(!strcmp(response,"broke")) sf=mij; if(!strcmp(response,"survived")) inc=mij; } } }