結果

問題 No.2252 Find Zero
ユーザー a01sa01toa01sa01to
提出日時 2023-07-29 00:04:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 651 bytes
コンパイル時間 2,168 ms
コンパイル使用メモリ 196,612 KB
実行使用メモリ 25,452 KB
平均クエリ数 121.33
最終ジャッジ日時 2024-04-16 07:57:55
合計ジャッジ時間 4,852 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 55 ms
25,452 KB
testcase_03 AC 72 ms
24,940 KB
testcase_04 AC 57 ms
25,324 KB
testcase_05 AC 54 ms
24,940 KB
testcase_06 AC 55 ms
24,940 KB
testcase_07 AC 54 ms
25,184 KB
testcase_08 AC 69 ms
25,220 KB
testcase_09 WA -
testcase_10 AC 56 ms
24,812 KB
testcase_11 AC 54 ms
25,196 KB
testcase_12 AC 55 ms
25,196 KB
testcase_13 AC 53 ms
25,324 KB
testcase_14 AC 53 ms
25,196 KB
testcase_15 WA -
testcase_16 AC 55 ms
24,556 KB
testcase_17 AC 54 ms
25,196 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);
  int cnt = 0;
  rep(i, n) {
    if (a[i]) continue;
    int z = i;
    if (cnt != n - 1) z = Query(i, i);
    if (z == i) {
      printf("! %d\n", i);
      fflush(stdout);
      return 0;
    }
    a[i] = a[z] = true;
    cnt += 2;
  }
  return 0;
}
0