結果
問題 | No.130 XOR Minimax |
ユーザー |
![]() |
提出日時 | 2020-09-23 15:12:53 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 167 ms / 5,000 ms |
コード長 | 751 bytes |
コンパイル時間 | 183 ms |
コンパイル使用メモリ | 82,576 KB |
実行使用メモリ | 90,944 KB |
最終ジャッジ日時 | 2024-09-12 22:58:35 |
合計ジャッジ時間 | 3,645 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#xor minimaxdef main():N = int(input())a = list(map(int, input().split()))a.sort()def solve(order, l, r):if order == -1:return 0if l > r:return 10**20if l == r:return 0else:new_r = r + 1for i in range(l, r+1):if (a[i]>> order) & 1:new_r = ibreakif l < new_r < r + 1:return min(solve(order-1, l, new_r-1), solve(order-1, new_r, r)) + (1 << order)else:return solve(order-1, l, r)ans = solve(30, 0, N-1)print(ans)returnif __name__ == "__main__":main()