Submission #1030350

# Submission time Handle Problem Language Result Execution time Memory
1030350 2024-07-22T03:22:56 Z kunzaZa183 Colors (BOI20_colors) C++17
0 / 100
3 ms 600 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  int n = 1e18;
  cin>>n;
  vector<int> precomp;
  int l = 1, r = n;
  while (l < r) {
    precomp.push_back((l + r) / 2);
    l = (l + r) / 2 + 1;
  }
  int cur = n;
  int left = 1;
  reverse(precomp.begin(), precomp.end());
  for (auto a : precomp) {
    if (left == 0) {
      cur += a;
      left = 1;
    } else if (left == 1) {
      cur -= a;
      left = 0;
    }
  }
  int tmpcur = cur, tmpleft = left;

  // for (int ans = 1e18; ans >= 1e18 - 1e6; ans--) {
  //   if (ans % 100 == 0) cout << ans << " ";
    int res;
    cout << "? " << cur << endl;
    cin >> res;
    cur = tmpcur, left = tmpleft;

    set<int> si;
    si.insert(cur);

    l = 1, r = n;
    while (l < r) {
      int mid = (l + r) / 2;
      int guess;
      if (left) {
        guess = cur - mid;
        left = 0;
      } else {
        guess = cur + mid;
        left = 1;
      }
      if (si.count(guess)) {
        while(1){}
        // cout << "FAILED " << ans << '\n';
        return 0;
      }
      si.insert(guess);
      cur = guess;
      // if (mid >= ans)
      //   r = mid;
      // else
      //   l = mid + 1;
      cout << "? " << cur << endl;
      cin >> res;
      if (res)
        r = mid;
      else
        l = mid + 1;
    }
    cout << "= " << l << endl;
    // if (l != ans) {
    //   cout << "WRONG " << ans << ' ' << l << '\n';
    //   return 0;
    // }
  // }
}
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -