結果

問題 No.130 XOR Minimax
ユーザー rlangevinrlangevin
提出日時 2023-11-28 00:04:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 493 ms / 5,000 ms
コード長 394 bytes
コンパイル時間 329 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 164,084 KB
最終ジャッジ日時 2023-11-28 00:04:16
合計ジャッジ時間 8,297 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 252 ms
111,556 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 35 ms
53,460 KB
testcase_04 AC 47 ms
70,084 KB
testcase_05 AC 55 ms
76,768 KB
testcase_06 AC 380 ms
164,084 KB
testcase_07 AC 398 ms
160,960 KB
testcase_08 AC 493 ms
153,920 KB
testcase_09 AC 105 ms
81,536 KB
testcase_10 AC 132 ms
90,760 KB
testcase_11 AC 270 ms
129,936 KB
testcase_12 AC 87 ms
78,504 KB
testcase_13 AC 227 ms
118,908 KB
testcase_14 AC 422 ms
146,192 KB
testcase_15 AC 68 ms
75,792 KB
testcase_16 AC 348 ms
128,308 KB
testcase_17 AC 324 ms
128,444 KB
testcase_18 AC 358 ms
133,748 KB
testcase_19 AC 400 ms
138,356 KB
testcase_20 AC 255 ms
107,148 KB
testcase_21 AC 464 ms
149,388 KB
testcase_22 AC 132 ms
81,872 KB
testcase_23 AC 82 ms
77,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(A, d):
    if d < 0:
        return 0
    L = [[], []]
    for i in range(len(A)):
        L[(A[i] >> d) & 1].append(A[i]^((1 << d)*((A[i] >> d) & 1)))
    if len(L[0]) == 0:
        return f(L[1], d-1)
    if len(L[1]) == 0:
        return f(L[0], d-1)
    return (1 << d) + min(f(L[0], d-1), f(L[1], d-1))
    
N = int(input())
A = list(set(map(int, input().split())))

print(f(A, 65))
0