結果

問題 No.130 XOR Minimax
ユーザー konsin_tokagekonsin_tokage
提出日時 2018-03-30 23:13:10
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 388 bytes
コンパイル時間 573 ms
コンパイル使用メモリ 86,868 KB
実行使用メモリ 211,860 KB
最終ジャッジ日時 2023-09-08 07:38:41
合計ジャッジ時間 7,257 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 73 ms
70,936 KB
testcase_02 AC 76 ms
71,208 KB
testcase_03 AC 76 ms
71,172 KB
testcase_04 AC 236 ms
211,860 KB
testcase_05 AC 238 ms
174,140 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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
n = int(input())
a = list(map(int, input().split()))
def dfs(a, i):
    if i < 0:
        return 0
    x = []
    y = []
    for j in a:
        if j&(1<<i) == 0:
            x.append(j)
        else:
            y.append(j)
    if not x:
        return dfs(y, i-1)
    elif not y:
        return dfs(x, i-1)
    return (1<<i) + max(dfs(x, i-1), dfs(y, i-1))
print(dfs(a, 30))
0