結果

問題 No.130 XOR Minimax
ユーザー konsin_tokagekonsin_tokage
提出日時 2018-03-30 23:44:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 277 ms / 5,000 ms
コード長 376 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 87,116 KB
実行使用メモリ 211,860 KB
最終ジャッジ日時 2023-10-10 00:22:48
合計ジャッジ時間 5,739 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 186 ms
85,152 KB
testcase_01 AC 62 ms
71,704 KB
testcase_02 AC 62 ms
71,512 KB
testcase_03 AC 62 ms
71,404 KB
testcase_04 AC 199 ms
211,860 KB
testcase_05 AC 199 ms
174,188 KB
testcase_06 AC 179 ms
140,060 KB
testcase_07 AC 199 ms
146,984 KB
testcase_08 AC 272 ms
103,180 KB
testcase_09 AC 116 ms
80,248 KB
testcase_10 AC 127 ms
84,596 KB
testcase_11 AC 202 ms
131,252 KB
testcase_12 AC 106 ms
78,852 KB
testcase_13 AC 170 ms
114,256 KB
testcase_14 AC 273 ms
99,176 KB
testcase_15 AC 92 ms
77,840 KB
testcase_16 AC 211 ms
90,776 KB
testcase_17 AC 233 ms
91,144 KB
testcase_18 AC 246 ms
93,068 KB
testcase_19 AC 274 ms
96,620 KB
testcase_20 AC 189 ms
84,876 KB
testcase_21 AC 277 ms
98,728 KB
testcase_22 AC 139 ms
79,208 KB
testcase_23 AC 112 ms
78,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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) + min(dfs(x, i-1), dfs(y, i-1))
print(dfs(a, 30))
0