結果

問題 No.514 宝探し3
ユーザー cympfhcympfh
提出日時 2017-05-05 22:39:24
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 536 bytes
コンパイル時間 210 ms
コンパイル使用メモリ 11,572 KB
実行使用メモリ 31,708 KB
平均クエリ数 107.00
最終ジャッジ日時 2023-09-23 13:21:05
合計ジャッジ時間 4,215 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

M = 1000000000

def get(x, y)

  x = [M, [0, x].max].min
  y = [M, [0, y].max].min

  puts "#{x} #{y}"
  STDOUT.flush
  d = gets.to_i
  return d
end

y = M / 2
left = 0
right = M

while right - left > 2
  x1 = (left + left + right) / 3
  x2 = (left + right + right) / 3
  d1 = get(x1, y)
  d2 = get(x2, y)
  if d1 < d2
    right = x2
  else
    left = x1
  end
end

mn_d = M * M
mn_x = left

((left - 2)..(left + 2)).each do |x|
  d = get(x, y)
  if d < mn_d
    mn_d = d
    mn_x = x
  end
end

get(mn_x, y + mn_d)
get(mn_x, y - mn_d)
0