結果

問題 No.130 XOR Minimax
ユーザー tktk_snsntktk_snsn
提出日時 2020-12-25 20:34:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 692 ms / 5,000 ms
コード長 593 bytes
コンパイル時間 204 ms
コンパイル使用メモリ 11,908 KB
実行使用メモリ 41,272 KB
最終ジャッジ日時 2023-10-23 20:24:32
合計ジャッジ時間 9,201 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 330 ms
14,520 KB
testcase_01 AC 28 ms
10,112 KB
testcase_02 AC 28 ms
10,112 KB
testcase_03 AC 27 ms
10,112 KB
testcase_04 AC 258 ms
36,544 KB
testcase_05 AC 319 ms
41,272 KB
testcase_06 AC 363 ms
29,896 KB
testcase_07 AC 381 ms
29,392 KB
testcase_08 AC 692 ms
19,624 KB
testcase_09 AC 87 ms
13,540 KB
testcase_10 AC 116 ms
15,312 KB
testcase_11 AC 317 ms
27,672 KB
testcase_12 AC 57 ms
11,732 KB
testcase_13 AC 261 ms
24,612 KB
testcase_14 AC 595 ms
18,696 KB
testcase_15 AC 33 ms
10,176 KB
testcase_16 AC 430 ms
16,444 KB
testcase_17 AC 452 ms
16,644 KB
testcase_18 AC 477 ms
17,328 KB
testcase_19 AC 566 ms
17,956 KB
testcase_20 AC 292 ms
14,856 KB
testcase_21 AC 600 ms
18,620 KB
testcase_22 AC 157 ms
12,052 KB
testcase_23 AC 68 ms
10,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

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


def rec(X, val, d):
    if d < 0:
        global ans
        ans = min(ans, val)
        return

    zero = []
    one = []
    for a in X:
        if (a >> d) & 1:
            one.append(a)
        else:
            zero.append(a)
    if one and zero:
        val += 1 << d
        rec(one, val, d - 1)
        rec(zero, val, d - 1)
    elif zero:
        rec(zero, val, d - 1)
    elif one:
        rec(one, val, d - 1)


rec(A, 0, 32)
print(ans)
0