結果

問題 No.2252 Find Zero
ユーザー a01sa01toa01sa01to
提出日時 2023-07-29 00:09:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 656 bytes
コンパイル時間 2,245 ms
コンパイル使用メモリ 195,864 KB
実行使用メモリ 25,220 KB
平均クエリ数 78.17
最終ジャッジ日時 2024-04-16 08:02:28
合計ジャッジ時間 4,769 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
24,940 KB
testcase_01 AC 80 ms
25,196 KB
testcase_02 AC 57 ms
24,812 KB
testcase_03 AC 68 ms
24,940 KB
testcase_04 AC 58 ms
24,940 KB
testcase_05 AC 56 ms
24,556 KB
testcase_06 AC 56 ms
25,196 KB
testcase_07 AC 56 ms
24,812 KB
testcase_08 AC 63 ms
25,220 KB
testcase_09 AC 67 ms
25,208 KB
testcase_10 AC 55 ms
25,196 KB
testcase_11 AC 55 ms
25,196 KB
testcase_12 AC 56 ms
25,196 KB
testcase_13 AC 57 ms
24,940 KB
testcase_14 AC 57 ms
24,796 KB
testcase_15 AC 56 ms
24,556 KB
testcase_16 AC 56 ms
24,940 KB
testcase_17 AC 56 ms
25,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
  #define _GLIBCXX_DEBUG
#else
  #define Debug(...) void(0)
#endif
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)

int Query(int x, int y) {
  printf("? %d %d\n", x, y);
  fflush(stdout);
  int z;
  cin >> z;
  return z;
}

int main() {
  int n;
  cin >> n;
  vector<bool> a(n, false);
  rep(i, n / 2) {
    if (a[i]) continue;
    int z = Query(2 * i, 2 * i + 1);
    if (z == 2 * i || z == 2 * i + 1) {
      printf("! %d\n", z ^ 1);
      fflush(stdout);
      return 0;
    }
  }
  printf("! %d\n", n - 1);
  fflush(stdout);
  return 0;
}
0