結果

問題 No.2252 Find Zero
ユーザー tnakao0123tnakao0123
提出日時 2023-05-18 16:42:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 629 bytes
コンパイル時間 340 ms
コンパイル使用メモリ 41,100 KB
実行使用メモリ 24,492 KB
平均クエリ数 78.39
最終ジャッジ日時 2023-08-22 10:42:27
合計ジャッジ時間 3,286 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 40 ms
24,168 KB
testcase_03 AC 52 ms
23,424 KB
testcase_04 AC 41 ms
23,424 KB
testcase_05 AC 39 ms
23,388 KB
testcase_06 AC 40 ms
24,216 KB
testcase_07 AC 40 ms
23,436 KB
testcase_08 AC 47 ms
24,036 KB
testcase_09 AC 52 ms
23,928 KB
testcase_10 AC 39 ms
23,724 KB
testcase_11 AC 41 ms
23,676 KB
testcase_12 WA -
testcase_13 AC 40 ms
23,424 KB
testcase_14 AC 39 ms
24,300 KB
testcase_15 WA -
testcase_16 AC 38 ms
23,544 KB
testcase_17 AC 39 ms
23,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2252.cc:  No.2252 Find Zero - yukicoder
 */

#include<cstdio>
#include<algorithm>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

int query(int i, int j) {
  printf("? %d %d\n", i, j); fflush(stdout);

  int x;
  scanf("%d", &x);
  return x;
}

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i += 2) {
    int j = i + 1;
    int x = query(i, j);
    if (i == x || j == x) {
      printf("! %d\n", (x != i) ? i : j); fflush(stdout);
      return 0;
    }
  }

  printf("! %d\n", n - 1); fflush(stdout);
  return 0;
}
0