結果

問題 No.130 XOR Minimax
ユーザー code-devocode-devo
提出日時 2016-02-06 08:40:43
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,143 ms / 5,000 ms
コード長 376 bytes
コンパイル時間 493 ms
コンパイル使用メモリ 11,524 KB
実行使用メモリ 47,252 KB
最終ジャッジ日時 2023-10-10 00:13:27
合計ジャッジ時間 13,510 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 560 ms
22,308 KB
testcase_01 AC 72 ms
15,288 KB
testcase_02 AC 73 ms
15,404 KB
testcase_03 AC 71 ms
15,300 KB
testcase_04 AC 110 ms
22,432 KB
testcase_05 AC 114 ms
23,168 KB
testcase_06 AC 536 ms
40,704 KB
testcase_07 AC 631 ms
47,252 KB
testcase_08 AC 1,143 ms
32,236 KB
testcase_09 AC 144 ms
18,256 KB
testcase_10 AC 186 ms
19,856 KB
testcase_11 AC 374 ms
30,716 KB
testcase_12 AC 116 ms
16,456 KB
testcase_13 AC 344 ms
27,704 KB
testcase_14 AC 1,075 ms
26,168 KB
testcase_15 AC 80 ms
15,468 KB
testcase_16 AC 736 ms
25,092 KB
testcase_17 AC 765 ms
25,688 KB
testcase_18 AC 814 ms
26,128 KB
testcase_19 AC 993 ms
25,448 KB
testcase_20 AC 507 ms
21,716 KB
testcase_21 AC 1,040 ms
25,820 KB
testcase_22 AC 288 ms
17,056 KB
testcase_23 AC 142 ms
15,588 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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)
0