結果
| 問題 |
No.513 宝探し2
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2020-12-10 08:56:54 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 721 bytes |
| コンパイル時間 | 239 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 29,064 KB |
| 平均クエリ数 | 84.50 |
| 最終ジャッジ日時 | 2024-07-17 09:58:03 |
| 合計ジャッジ時間 | 4,077 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 WA * 10 |
コンパイルメッセージ
Main.rb:27: warning: assigned but unused variable - ng Syntax OK
ソースコード
def ternary_search_tree(left, right)
loop_cnt = 24
loop_cnt.times do
if yield((left * 2 + right) / 3.0) < yield((left + right * 2) / 3.0)
right = (left + right * 2) / 3.0
else
left = (left * 2 + right) / 3.0
end
end
(left + right) / 2
end
cy = 0
cx = 0
STDOUT.puts("%d %d" % [cx, cy])
STDOUT.flush
current_d = gets.to_i
if current_d == 0
exit
end
ok = 0
ng = 100_001
cx = ternary_search_tree(0, 100_001) { |x|
STDOUT.puts("%d %d" % [x, cy])
STDOUT.flush
d = gets.to_i
if d == 0
exit
end
d
}
cx = ok
ok = 0
ng = 100_001
cy = ternary_search_tree(0, 100_001) { |y|
STDOUT.puts("%d %d" % [cx, y])
STDOUT.flush
d = gets.to_i
if d == 0
exit
end
d
}
siman