結果

問題 No.2252 Find Zero
ユーザー 👑 chro_96chro_96
提出日時 2023-03-24 21:26:05
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 395 bytes
コンパイル時間 1,450 ms
コンパイル使用メモリ 28,732 KB
実行使用メモリ 24,648 KB
平均クエリ数 195.33
最終ジャッジ日時 2023-10-18 20:41:33
合計ジャッジ時間 3,716 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
24,648 KB
testcase_01 AC 71 ms
24,648 KB
testcase_02 AC 69 ms
24,648 KB
testcase_03 AC 69 ms
24,648 KB
testcase_04 AC 60 ms
24,648 KB
testcase_05 AC 50 ms
24,648 KB
testcase_06 AC 64 ms
24,648 KB
testcase_07 AC 61 ms
24,648 KB
testcase_08 AC 70 ms
24,648 KB
testcase_09 AC 70 ms
24,648 KB
testcase_10 AC 48 ms
24,648 KB
testcase_11 AC 49 ms
24,648 KB
testcase_12 AC 49 ms
24,648 KB
testcase_13 AC 49 ms
24,648 KB
testcase_14 AC 49 ms
24,648 KB
testcase_15 AC 49 ms
24,648 KB
testcase_16 AC 50 ms
24,648 KB
testcase_17 AC 50 ms
24,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main () {
  int n = 0;
  int z = 0;
  
  int res = 0;
  
  int ans = 0;
  
  res = scanf("%d", &n);
  
  ans = n-1;
  for (int i = 0; i < n/2; i++) {
    printf("? %d %d\n", 2*i, 2*i+1);
    fflush(stdout);
    res = scanf("%d", &z);
    if (z == 2*i) {
      ans = 2*i+1;
    } else if (z == 2*i+1) {
      ans = 2*i;
    }
  }
  
  printf("! %d\n", ans);
  return 0;
}
0