結果

問題 No.130 XOR Minimax
ユーザー NoneNone
提出日時 2021-03-25 16:45:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 339 ms / 5,000 ms
コード長 447 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 86,920 KB
実行使用メモリ 211,396 KB
最終ジャッジ日時 2023-08-18 00:57:56
合計ジャッジ時間 6,954 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 229 ms
89,764 KB
testcase_01 AC 72 ms
70,896 KB
testcase_02 AC 74 ms
71,292 KB
testcase_03 AC 72 ms
70,896 KB
testcase_04 AC 206 ms
211,396 KB
testcase_05 AC 208 ms
167,892 KB
testcase_06 AC 194 ms
150,840 KB
testcase_07 AC 210 ms
143,164 KB
testcase_08 AC 339 ms
113,228 KB
testcase_09 AC 131 ms
80,352 KB
testcase_10 AC 141 ms
84,672 KB
testcase_11 AC 216 ms
140,480 KB
testcase_12 AC 119 ms
78,984 KB
testcase_13 AC 190 ms
120,908 KB
testcase_14 AC 322 ms
106,108 KB
testcase_15 AC 103 ms
77,480 KB
testcase_16 AC 260 ms
97,752 KB
testcase_17 AC 268 ms
98,104 KB
testcase_18 AC 284 ms
101,128 KB
testcase_19 AC 301 ms
102,528 KB
testcase_20 AC 212 ms
87,700 KB
testcase_21 AC 330 ms
105,952 KB
testcase_22 AC 153 ms
79,436 KB
testcase_23 AC 125 ms
78,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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))
0