結果

問題 No.130 XOR Minimax
ユーザー NoneNone
提出日時 2021-03-25 16:45:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 293 ms / 5,000 ms
コード長 447 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 218,240 KB
最終ジャッジ日時 2024-05-05 07:47:06
合計ジャッジ時間 5,028 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 175 ms
88,576 KB
testcase_01 AC 36 ms
52,224 KB
testcase_02 AC 37 ms
51,840 KB
testcase_03 AC 36 ms
51,200 KB
testcase_04 AC 182 ms
218,240 KB
testcase_05 AC 181 ms
174,976 KB
testcase_06 AC 155 ms
144,256 KB
testcase_07 AC 170 ms
142,848 KB
testcase_08 AC 293 ms
111,872 KB
testcase_09 AC 105 ms
77,696 KB
testcase_10 AC 107 ms
83,072 KB
testcase_11 AC 177 ms
129,408 KB
testcase_12 AC 91 ms
76,928 KB
testcase_13 AC 157 ms
119,552 KB
testcase_14 AC 270 ms
108,160 KB
testcase_15 AC 86 ms
75,008 KB
testcase_16 AC 225 ms
96,000 KB
testcase_17 AC 219 ms
96,640 KB
testcase_18 AC 233 ms
100,608 KB
testcase_19 AC 242 ms
104,448 KB
testcase_20 AC 167 ms
86,144 KB
testcase_21 AC 258 ms
108,032 KB
testcase_22 AC 118 ms
76,800 KB
testcase_23 AC 96 ms
76,800 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