結果

問題 No.130 XOR Minimax
コンテスト
ユーザー roiti46
提出日時 2015-02-26 00:02:35
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 359 ms / 5,000 ms
コード長 447 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 141 ms
コンパイル使用メモリ 77,464 KB
最終ジャッジ日時 2025-12-03 14:16:17
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def rec(shift, a):
    if shift < 0: return 0

    one  = [ai ^ (ai & (1 << shift)) for ai in a if     ai & (1 << shift)]
    zero = [ai ^ (ai & (1 << shift)) for ai in a if not ai & (1 << shift)]
    
    if not zero: return rec(shift - 1,  one)
    if not  one: return rec(shift - 1, zero)

    return (1 << shift) + min(rec(shift - 1, zero), rec(shift - 1, one))

N = int(raw_input())
A = list(set(map(int,raw_input().split())))
print rec(30,A)
0