結果
| 問題 |
No.850 企業コンテスト2位
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-07-05 23:10:09 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 141 ms / 2,000 ms |
| コード長 | 422 bytes |
| コンパイル時間 | 139 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 29,144 KB |
| 平均クエリ数 | 200.11 |
| 最終ジャッジ日時 | 2024-07-16 17:32:36 |
| 合計ジャッジ時間 | 6,012 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 27 |
コンパイルメッセージ
Syntax OK
ソースコード
$>.sync = true
N = gets.to_i
$res = Hash.new []
def f(a)
while a.size > 1
new_a = []
a.each_slice(2){|x, y|
if y.nil?
new_a << x
next
end
puts"? #{x} #{y}"
z = gets.to_i
new_a << z
if z == x
$res[x] += [y]
else
$res[y] += [x]
end
}
a = new_a
end
a[0]
end
first = f([*1..N])
second = f($res[first])
puts "! #{second}"