Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- bool f,g;
- string s;
- long long l,r;
- int main()
- {
- f=1;
- while (1)
- {
- cin >> s;
- if (s=="end") break;
- cout << "? " << 0 << " " << 1 << endl;
- fflush(stdout);
- cin >> s;
- if (s=="x")
- {
- cout << "!1";
- continue;
- }
- l=1;
- r=2;
- f=0;
- g=1;
- while (!f)
- {
- if (g==0)
- {
- l*=2;
- r*=2;
- }
- cout << "? " << l << " " << r << endl;
- fflush(stdout);
- cin >> s;
- f=(s=="x");
- g=0;
- }
- f=(l==r-1);
- while (!f)
- {
- cout << "? " << l << " " << (l+r)/2 << endl;
- fflush(stdout);
- cin >> s;
- if (s=="x") r=(l+r)/2;
- if (s=="y") l=(l+r)/2;
- f=(l==r-1);
- }
- cout << "! " << r << endl;
- fflush(stdout);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement