結果

問題 No.594 壊れた宝物発見機
ユーザー 0w10w1
提出日時 2017-11-20 11:30:48
言語 Ruby
(3.3.0)
結果
AC  
実行時間 203 ms / 2,000 ms
コード長 390 bytes
コンパイル時間 69 ms
コンパイル使用メモリ 11,380 KB
実行使用メモリ 31,540 KB
平均クエリ数 46.60
最終ジャッジ日時 2023-09-23 15:07:57
合計ジャッジ時間 5,484 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 202 ms
31,476 KB
testcase_01 AC 203 ms
31,104 KB
testcase_02 AC 193 ms
31,060 KB
testcase_03 AC 194 ms
31,292 KB
testcase_04 AC 187 ms
31,108 KB
testcase_05 AC 186 ms
31,104 KB
testcase_06 AC 191 ms
30,976 KB
testcase_07 AC 189 ms
30,896 KB
testcase_08 AC 190 ms
31,076 KB
testcase_09 AC 191 ms
30,864 KB
testcase_10 AC 189 ms
30,760 KB
testcase_11 AC 198 ms
31,188 KB
testcase_12 AC 194 ms
30,896 KB
testcase_13 AC 194 ms
31,268 KB
testcase_14 AC 200 ms
31,460 KB
testcase_15 AC 196 ms
31,284 KB
testcase_16 AC 194 ms
30,916 KB
testcase_17 AC 191 ms
30,828 KB
testcase_18 AC 199 ms
31,540 KB
testcase_19 AC 200 ms
31,104 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:30: warning: `*' interpreted as argument prefix
Syntax OK

ソースコード

diff #

def ask x, y, z
  puts "? #{x} #{y} #{z}"
  $>.flush
  gets.to_i
end

def sho x, y, z
  puts "! #{x} #{y} #{z}"
end

ans = [0] * 3

3.times do |i|
  lb, ub = -101, 100
  until lb + 1 == ub
    mb = lb + ub >> 1
    q1 = [0, 0, 0]
    q1[i] = mb
    q2 = [0, 0, 0]
    q2[i] = mb + 1
    if ask(*q1) <= ask(*q2)
      ub = mb
    else
      lb = mb
    end
  end
  ans[i] = ub
end

sho *ans
0