Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. bool f,g;
  6. string s;
  7. long long l,r;
  8.  
  9. int main()
  10. {
  11. f=1;
  12. while (1)
  13. {
  14. cin >> s;
  15. if (s=="end") break;
  16. cout << "? " << 0 << " " << 1 << endl;
  17. fflush(stdout);
  18. cin >> s;
  19. if (s=="x")
  20. {
  21. cout << "!1";
  22. continue;
  23. }
  24. l=1;
  25. r=2;
  26. f=0;
  27. g=1;
  28. while (!f)
  29. {
  30. if (g==0)
  31. {
  32. l*=2;
  33. r*=2;
  34. }
  35. cout << "? " << l << " " << r << endl;
  36. fflush(stdout);
  37. cin >> s;
  38. f=(s=="x");
  39. g=0;
  40. }
  41. f=(l==r-1);
  42.  
  43. while (!f)
  44. {
  45. cout << "? " << l << " " << (l+r)/2 << endl;
  46. fflush(stdout);
  47. cin >> s;
  48. if (s=="x") r=(l+r)/2;
  49. if (s=="y") l=(l+r)/2;
  50. f=(l==r-1);
  51. }
  52. cout << "! " << r << endl;
  53. fflush(stdout);
  54. }
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement