Advertisement
skaram

Untitled

Mar 12th, 2024
584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.51 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #ifndef Local
  4. #define debug(...) 1337
  5. //#define endl '\n'
  6. #endif
  7.  
  8. using namespace std;
  9.  
  10. #define int long long
  11.  
  12. typedef long long ll;
  13. typedef long double ld;
  14.  
  15. #define all(x) (x).begin(), (x).end()
  16. #define sz(x) (int)(x).size()
  17.  
  18. template<class A, class B>
  19. bool smin(A &x, B &&y) {
  20.         if (x > y) {
  21.                 x = y;
  22.                 return true;
  23.         }
  24.         return false;
  25. }
  26.  
  27. template<class A, class B>
  28. bool smax(A &x, B &&y) {
  29.         if (x < y) {
  30.                 x = y;
  31.                 return true;
  32.         }
  33.         return false;
  34. }
  35.  
  36. double get(int x, int y) {
  37.         cout << "? " << x << ' ' << y << endl;
  38.         double a;
  39.         cin >> a;
  40.         return a;
  41. }
  42.  
  43. void solve() {
  44.         int x, y;
  45.         cin >> x >> y;
  46.         int l = 0, r = x;
  47.         while (r - l > 1) {
  48.                 int m = (l + r) / 2;
  49.                 if (get(m, 1) < get(m + 1, 1))
  50.                         l = m;
  51.                 else
  52.                         r = m;
  53.         }
  54.         int a = r;
  55.         l = 0, r = y;
  56.         while (r - l > 1) {
  57.                 int m = (l + r) / 2;
  58.                 if (get(1, m) < get(1, m + 1))
  59.                         l = m;
  60.                 else
  61.                         r = m;
  62.         }
  63.         cout << "! " << a << ' ' << r << endl;
  64. }
  65.  
  66. signed main() {
  67. //        ios::sync_with_stdio(false), cin.tie(nullptr);
  68.  
  69.         int tt = 1;
  70. //        cin >> tt;
  71.         while (tt--)
  72.                 solve();
  73.  
  74.         return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement