結果

問題 No.130 XOR Minimax
ユーザー hahhohahho
提出日時 2021-03-26 18:22:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 214 ms / 5,000 ms
コード長 494 bytes
コンパイル時間 385 ms
コンパイル使用メモリ 86,984 KB
実行使用メモリ 91,712 KB
最終ジャッジ日時 2023-08-19 02:20:49
合計ジャッジ時間 5,046 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 159 ms
82,148 KB
testcase_01 AC 62 ms
70,960 KB
testcase_02 AC 62 ms
71,376 KB
testcase_03 AC 63 ms
71,228 KB
testcase_04 AC 79 ms
88,256 KB
testcase_05 AC 86 ms
90,944 KB
testcase_06 AC 116 ms
90,160 KB
testcase_07 AC 129 ms
91,712 KB
testcase_08 AC 142 ms
91,500 KB
testcase_09 AC 155 ms
78,624 KB
testcase_10 AC 121 ms
78,808 KB
testcase_11 AC 159 ms
89,436 KB
testcase_12 AC 106 ms
77,648 KB
testcase_13 AC 159 ms
86,204 KB
testcase_14 AC 149 ms
90,692 KB
testcase_15 AC 72 ms
75,292 KB
testcase_16 AC 214 ms
86,244 KB
testcase_17 AC 143 ms
85,768 KB
testcase_18 AC 144 ms
86,936 KB
testcase_19 AC 176 ms
88,848 KB
testcase_20 AC 138 ms
82,196 KB
testcase_21 AC 155 ms
90,212 KB
testcase_22 AC 136 ms
78,652 KB
testcase_23 AC 87 ms
77,636 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