Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- char ans;
- void ask(int x, int y) {
- cout << "? " << x << " " << y << endl;
- cin >> ans;
- }
- int main() {
- string s;
- cin >> s;
- while (s != "end") {
- int curp = 1, prp = 0;
- ask(0, curp);
- while (ans == 'y') {
- prp = curp;
- curp *= 2;
- ask(prp, curp);
- }
- int L = prp, R = curp;
- while (R - L > 1) {
- int MID = L + R >> 1;
- ask(L, MID);
- if (ans == 'x')
- R = MID;
- else
- L = MID;
- }
- cout << "! " << R << endl;
- cin >> s;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement