結果

問題 No.130 XOR Minimax
ユーザー 👑 hahhohahho
提出日時 2021-03-26 18:22:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 204 ms / 5,000 ms
コード長 494 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 82,184 KB
実行使用メモリ 90,712 KB
最終ジャッジ日時 2024-05-06 09:31:11
合計ジャッジ時間 4,272 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
81,408 KB
testcase_01 AC 38 ms
52,168 KB
testcase_02 AC 39 ms
51,968 KB
testcase_03 AC 39 ms
51,968 KB
testcase_04 AC 58 ms
76,672 KB
testcase_05 AC 64 ms
83,072 KB
testcase_06 AC 119 ms
89,216 KB
testcase_07 AC 107 ms
90,496 KB
testcase_08 AC 135 ms
90,712 KB
testcase_09 AC 147 ms
76,936 KB
testcase_10 AC 109 ms
77,952 KB
testcase_11 AC 149 ms
87,936 KB
testcase_12 AC 88 ms
76,140 KB
testcase_13 AC 151 ms
85,120 KB
testcase_14 AC 144 ms
88,904 KB
testcase_15 AC 49 ms
60,032 KB
testcase_16 AC 204 ms
84,096 KB
testcase_17 AC 139 ms
84,132 KB
testcase_18 AC 146 ms
85,376 KB
testcase_19 AC 177 ms
87,552 KB
testcase_20 AC 136 ms
80,640 KB
testcase_21 AC 150 ms
88,948 KB
testcase_22 AC 109 ms
76,800 KB
testcase_23 AC 79 ms
75,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left
max2 = lambda x,y: x if x > y else y
min2 = lambda x,y: x if x < y else y

def solve(a):
    a.sort()
    def rec(d,l,r):
        if l + 1 == r or d == 0:
            return 0
        i = a[l]&(-1 << d)|(1<<(d-1))
        m = bisect_left(a,i,l,r)
        if l == m or r == m:
            return rec(d-1,l,r)
        return min2(rec(d-1,l,m),rec(d-1,m,r))|(1<<(d-1))
    return rec(32,0,len(a))


n = int(input())
a = list(map(int,input().split()))
print(solve(a))
0