結果

問題 No.130 XOR Minimax
ユーザー H3PO4H3PO4
提出日時 2024-04-15 09:35:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 939 ms / 5,000 ms
コード長 405 bytes
コンパイル時間 234 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 79,616 KB
最終ジャッジ日時 2024-04-15 09:36:05
合計ジャッジ時間 12,069 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 422 ms
15,500 KB
testcase_01 AC 37 ms
10,752 KB
testcase_02 AC 35 ms
10,880 KB
testcase_03 AC 36 ms
10,752 KB
testcase_04 AC 277 ms
35,720 KB
testcase_05 AC 553 ms
79,616 KB
testcase_06 AC 455 ms
30,572 KB
testcase_07 AC 637 ms
57,144 KB
testcase_08 AC 939 ms
21,780 KB
testcase_09 AC 103 ms
13,952 KB
testcase_10 AC 150 ms
16,248 KB
testcase_11 AC 404 ms
27,608 KB
testcase_12 AC 70 ms
12,160 KB
testcase_13 AC 334 ms
24,268 KB
testcase_14 AC 791 ms
19,856 KB
testcase_15 AC 45 ms
10,752 KB
testcase_16 AC 565 ms
17,036 KB
testcase_17 AC 693 ms
17,344 KB
testcase_18 AC 633 ms
17,920 KB
testcase_19 AC 764 ms
19,212 KB
testcase_20 AC 384 ms
15,264 KB
testcase_21 AC 795 ms
19,800 KB
testcase_22 AC 198 ms
13,184 KB
testcase_23 AC 84 ms
11,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))

def rec(X, digit):
    if digit == -1:
        return 0
    X0, X1 = [], []
    for x in X:
        if x >> digit & 1:
            X1.append(x ^ (1 << digit))
        else:
            X0.append(x)
    if X0 and X1:
        return (1 << digit) + min(rec(X0, digit - 1), rec(X1, digit - 1))
    else:
        return rec(X, digit - 1)

print(rec(A, 30))
0