結果
問題 | No.130 XOR Minimax |
ユーザー | WSKR |
提出日時 | 2020-09-23 15:10:50 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 751 bytes |
コンパイル時間 | 287 ms |
コンパイル使用メモリ | 10,920 KB |
実行使用メモリ | 19,700 KB |
最終ジャッジ日時 | 2023-09-10 07:14:10 |
合計ジャッジ時間 | 6,302 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 16 ms
7,716 KB |
testcase_02 | AC | 15 ms
7,808 KB |
testcase_03 | AC | 16 ms
7,796 KB |
testcase_04 | AC | 233 ms
9,868 KB |
testcase_05 | AC | 200 ms
18,944 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
ソースコード
#xor minimax def main(): N = int(input()) a = list(map(int, input().split())) a.sort() def solve(order, l, r): if order == -1: return 0 if l > r: return 10**20 if l == r: return 0 else: new_r = r + 1 for i in range(l, r+1): if (a[i]>> order) & 1: new_r = i break if l < new_r < r + 1: return max(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) return if __name__ == "__main__": main()