結果

問題 No.594 壊れた宝物発見機
ユーザー 0w10w1
提出日時 2017-11-20 11:31:32
言語 Ruby
(3.2.2)
結果
WA  
実行時間 -
コード長 830 bytes
コンパイル時間 65 ms
コンパイル使用メモリ 11,400 KB
実行使用メモリ 31,856 KB
平均クエリ数 52.45
最終ジャッジ日時 2023-09-23 15:07:51
合計ジャッジ時間 5,714 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 208 ms
31,260 KB
testcase_14 WA -
testcase_15 AC 206 ms
31,580 KB
testcase_16 AC 201 ms
31,288 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:45: 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}"
  $>.flush
  @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 = -100, 100
  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