結果
問題 | No.130 XOR Minimax |
ユーザー |
|
提出日時 | 2015-02-26 00:02:35 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 1,164 ms / 5,000 ms |
コード長 | 447 bytes |
コンパイル時間 | 148 ms |
コンパイル使用メモリ | 7,040 KB |
実行使用メモリ | 61,516 KB |
最終ジャッジ日時 | 2024-09-12 22:34:43 |
合計ジャッジ時間 | 11,803 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
def rec(shift, a):if shift < 0: return 0one = [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)