답안 #686643

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
686643 2023-01-25T15:56:36 Z null_awe Colors (BOI20_colors) C++14
0 / 100
1 ms 248 KB
#include <iostream>
#include <set>
using namespace std;

#define int long long

int n, at;
set<int> s;

bool qry(int x) {
  if (at <= n / 2 && at + x <= n) at += x;
  else at -= x;
  // if (s.count(at)) exit(0);
  cout << "? " << at << endl;
  s.insert(at);
  bool ans; cin >> ans;
  return ans;
}

int32_t main() {
  cin >> n;
  bool added = true;
  int left = n;
  at = 1;
  for (int i = (left + 1) / 2; i > 0; left >>= 1, i = (left + 1) / 2) {
    if (!added) at += i;
    added = !added;
    if (i == 1) break;
  }
  cout << "? " << at << endl;
  int tmp; cin >> tmp;
  s.insert(at);
  int sum = 0;
  left = n;
  for (int i = (left + 1) / 2; i > 0; left >>= 1, i = (left + 1) / 2) {
    int chg = sum + i;
    if (chg >= n) continue;
    if (!qry(chg)) sum = chg;
    if (i == 1) break;
  }
  cout << "= " << sum + 1 << '\n';
  return 0;
}

/*
49
25
12
6
3
2
1
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB OK (4 queries)
2 Correct 1 ms 208 KB OK (7 queries)
3 Correct 0 ms 208 KB OK (4 queries)
4 Correct 1 ms 208 KB OK (6 queries)
5 Incorrect 0 ms 248 KB Wrong guess
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB OK (4 queries)
2 Correct 1 ms 208 KB OK (7 queries)
3 Correct 0 ms 208 KB OK (4 queries)
4 Correct 1 ms 208 KB OK (6 queries)
5 Incorrect 0 ms 248 KB Wrong guess
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB OK (4 queries)
2 Correct 1 ms 208 KB OK (7 queries)
3 Correct 0 ms 208 KB OK (4 queries)
4 Correct 1 ms 208 KB OK (6 queries)
5 Incorrect 0 ms 248 KB Wrong guess
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB OK (4 queries)
2 Correct 1 ms 208 KB OK (7 queries)
3 Correct 0 ms 208 KB OK (4 queries)
4 Correct 1 ms 208 KB OK (6 queries)
5 Incorrect 0 ms 248 KB Wrong guess
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB OK (4 queries)
2 Correct 1 ms 208 KB OK (7 queries)
3 Correct 0 ms 208 KB OK (4 queries)
4 Correct 1 ms 208 KB OK (6 queries)
5 Incorrect 0 ms 248 KB Wrong guess
6 Halted 0 ms 0 KB -