結果
問題 | No.130 XOR Minimax |
ユーザー |
|
提出日時 | 2021-03-25 16:45:49 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 301 ms / 5,000 ms |
コード長 | 447 bytes |
コンパイル時間 | 356 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 218,112 KB |
最終ジャッジ日時 | 2024-11-27 02:36:32 |
合計ジャッジ時間 | 5,301 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
import sys sys.setrecursionlimit(10 ** 9) N=int(input()) A=list(map(int, input().split())) def dfs(array, i): if i<0:return 0 zero=[] one=[] for a in array: if (a>>i)&1: one.append(a^(1<<i)) else: zero.append(a) if not one: return dfs(array,i-1) elif not zero: return dfs(array,i-1) else: return (1<<i)+min(dfs(one,i-1),dfs(zero,i-1)) print(dfs(A,32))