結果

問題 No.594 壊れた宝物発見機
ユーザー 0w10w1
提出日時 2017-11-20 11:15:45
言語 Ruby
(3.2.2)
結果
TLE  
実行時間 -
コード長 819 bytes
コンパイル時間 60 ms
コンパイル使用メモリ 11,232 KB
実行使用メモリ 51,196 KB
最終ジャッジ日時 2023-09-23 15:45:58
合計ジャッジ時間 6,459 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:44: warning: `*' interpreted as argument prefix
Syntax OK

ソースコード

diff #

def ask x, y, z
  @memo ||= {}
  return @memo[[x, y, z]] if @memo.key? [x, y, z]
  puts "? #{x} #{y} #{z}"
  @memo[[x, y, z]] = gets.to_i
end

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

ans = [0] * 3

3.times do |i|
  ld, ud = -150, 150
  until ud - ld < 3
    xd, yd = ld + (ud - ld) / 3, ud - (ud - ld) / 3
    ll, xx, yy, uu = 0, 0, 0, 0
    q = [0, 0, 0]
    "lxyu".chars.each do |c|
      eval("q[i] = #{c}d")
      eval("#{c}#{c} = ask(*q)")
    end
    if ll <= xx && xx <= yy && yy <= uu
      ud = xd
    elsif ll >= xx && xx <= yy && yy <= uu
      ud = yd
    elsif ll >= xx && xx >= yy && yy <= uu
      ld = xd
    else
      ld = yd
    end
  end
  best, z = 100000, 0
  ld.upto(ud) do |j|
    q = [0, 0, 0]
    q[i] = j
    d = ask(*q)
    best, z = d, j if best > d
  end
  ans[i] = z
end

sho *ans
0