結果

問題 No.130 XOR Minimax
ユーザー konsin_tokagekonsin_tokage
提出日時 2018-03-31 00:33:55
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 683 ms / 5,000 ms
コード長 349 bytes
コンパイル時間 108 ms
コンパイル使用メモリ 10,752 KB
実行使用メモリ 19,836 KB
最終ジャッジ日時 2023-10-10 00:23:13
合計ジャッジ時間 7,944 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 305 ms
12,816 KB
testcase_01 AC 16 ms
7,932 KB
testcase_02 AC 14 ms
8,092 KB
testcase_03 AC 14 ms
7,984 KB
testcase_04 AC 220 ms
10,000 KB
testcase_05 AC 187 ms
19,008 KB
testcase_06 AC 274 ms
19,836 KB
testcase_07 AC 244 ms
18,860 KB
testcase_08 AC 683 ms
19,048 KB
testcase_09 AC 65 ms
9,736 KB
testcase_10 AC 89 ms
10,804 KB
testcase_11 AC 256 ms
17,620 KB
testcase_12 AC 41 ms
8,936 KB
testcase_13 AC 216 ms
15,604 KB
testcase_14 AC 555 ms
17,196 KB
testcase_15 AC 21 ms
8,028 KB
testcase_16 AC 392 ms
14,396 KB
testcase_17 AC 414 ms
14,784 KB
testcase_18 AC 449 ms
15,252 KB
testcase_19 AC 514 ms
16,536 KB
testcase_20 AC 274 ms
12,172 KB
testcase_21 AC 553 ms
17,200 KB
testcase_22 AC 138 ms
9,836 KB
testcase_23 AC 54 ms
8,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *
n = int(input())
a = sorted(map(int, input().split()))
def dfs(l, r, i):
    if i < 0:
        return 0
    for m in range(l, r):
        if (a[m]>>i)&1:
            break
    else:
        m += 1
    if m == l or m == r:
        return dfs(l, r, i-1)
    return (1<<i) + min(dfs(l, m, i-1), dfs(m, r, i-1))
print(dfs(0, n, 30))
0