結果

問題 No.130 XOR Minimax
ユーザー hahhohahho
提出日時 2021-03-26 17:47:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 219 ms / 5,000 ms
コード長 490 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 82,440 KB
実行使用メモリ 90,844 KB
最終ジャッジ日時 2024-05-06 08:44:28
合計ジャッジ時間 4,372 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 164 ms
81,164 KB
testcase_01 AC 37 ms
53,136 KB
testcase_02 AC 37 ms
53,356 KB
testcase_03 AC 37 ms
52,412 KB
testcase_04 AC 54 ms
77,184 KB
testcase_05 AC 61 ms
83,448 KB
testcase_06 AC 123 ms
89,508 KB
testcase_07 AC 122 ms
90,844 KB
testcase_08 AC 133 ms
90,392 KB
testcase_09 AC 98 ms
76,616 KB
testcase_10 AC 105 ms
77,320 KB
testcase_11 AC 130 ms
88,492 KB
testcase_12 AC 82 ms
76,328 KB
testcase_13 AC 116 ms
84,748 KB
testcase_14 AC 212 ms
89,220 KB
testcase_15 AC 49 ms
63,696 KB
testcase_16 AC 120 ms
84,044 KB
testcase_17 AC 142 ms
84,096 KB
testcase_18 AC 198 ms
85,952 KB
testcase_19 AC 219 ms
88,100 KB
testcase_20 AC 101 ms
80,784 KB
testcase_21 AC 174 ms
89,220 KB
testcase_22 AC 81 ms
76,616 KB
testcase_23 AC 93 ms
76,492 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)
        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