結果
問題 |
No.130 XOR Minimax
|
ユーザー |
|
提出日時 | 2016-02-06 08:40:43 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 1,466 ms / 5,000 ms |
コード長 | 376 bytes |
コンパイル時間 | 341 ms |
コンパイル使用メモリ | 7,680 KB |
実行使用メモリ | 38,992 KB |
最終ジャッジ日時 | 2024-09-12 22:39:50 |
合計ジャッジ時間 | 15,325 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
コンパイルメッセージ
Syntax OK
ソースコード
def calc(a, b) return a[0] if b < 0 mask = 2 ** b p0, p1 = a.partition{|n| n & mask == 0} if p0.empty? then return calc(p1.map{|n| n ^ mask}, b - 1) elsif p1.empty? then return calc(p0, b - 1) else v1 = calc(p0.map{|n| n ^ mask}, b - 1) v2 = calc(p1, b - 1) return [v1, v2].min end end gets a = gets.split.map(&:to_i).uniq puts calc(a, 30)