結果

問題 No.2252 Find Zero
ユーザー simansiman
提出日時 2023-03-25 04:16:18
言語 Ruby
(3.3.0)
結果
AC  
実行時間 174 ms / 2,000 ms
コード長 340 bytes
コンパイル時間 589 ms
コンパイル使用メモリ 11,896 KB
実行使用メモリ 32,400 KB
平均クエリ数 78.17
最終ジャッジ日時 2023-10-18 21:54:09
合計ジャッジ時間 5,681 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 159 ms
32,392 KB
testcase_01 AC 174 ms
32,392 KB
testcase_02 AC 147 ms
32,392 KB
testcase_03 AC 159 ms
32,392 KB
testcase_04 AC 147 ms
32,400 KB
testcase_05 AC 147 ms
32,400 KB
testcase_06 AC 147 ms
32,400 KB
testcase_07 AC 146 ms
32,400 KB
testcase_08 AC 157 ms
32,392 KB
testcase_09 AC 157 ms
32,392 KB
testcase_10 AC 140 ms
32,400 KB
testcase_11 AC 143 ms
32,400 KB
testcase_12 AC 143 ms
32,400 KB
testcase_13 AC 145 ms
32,400 KB
testcase_14 AC 145 ms
32,400 KB
testcase_15 AC 144 ms
32,400 KB
testcase_16 AC 144 ms
32,400 KB
testcase_17 AC 142 ms
32,400 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i

def query(x, y)
  STDOUT.puts("? #{x} #{y}")
  STDOUT.flush

  gets.to_i
end

(N / 2).times do |i|
  x = 2 * i
  y = 2 * i + 1

  z = query(x, y)

  if z == x
    STDOUT.puts "! #{y}"
    STDOUT.flush
    exit
  elsif z == y
    STDOUT.puts "! #{x}"
    STDOUT.flush
    exit
  end
end

STDOUT.puts "! #{N - 1}"
STDOUT.flush
0