結果

問題 No.130 XOR Minimax
ユーザー hahho28hahho28
提出日時 2021-03-26 17:47:24
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 223 ms / 5,000 ms
コード長 490 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 92,004 KB
最終ジャッジ日時 2023-08-19 01:35:22
合計ジャッジ時間 6,177 ms
ジャッジサーバーID
(参考情報)
judge15 / judge9
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 177 ms
83,192 KB
testcase_01 AC 62 ms
71,308 KB
testcase_02 AC 60 ms
71,480 KB
testcase_03 AC 61 ms
71,200 KB
testcase_04 AC 78 ms
88,348 KB
testcase_05 AC 82 ms
90,880 KB
testcase_06 AC 137 ms
90,748 KB
testcase_07 AC 141 ms
91,644 KB
testcase_08 AC 152 ms
92,004 KB
testcase_09 AC 116 ms
78,576 KB
testcase_10 AC 123 ms
78,904 KB
testcase_11 AC 144 ms
89,856 KB
testcase_12 AC 101 ms
78,564 KB
testcase_13 AC 127 ms
86,204 KB
testcase_14 AC 223 ms
90,540 KB
testcase_15 AC 74 ms
76,000 KB
testcase_16 AC 140 ms
85,388 KB
testcase_17 AC 173 ms
86,364 KB
testcase_18 AC 212 ms
87,096 KB
testcase_19 AC 217 ms
89,056 KB
testcase_20 AC 114 ms
81,708 KB
testcase_21 AC 187 ms
90,716 KB
testcase_22 AC 96 ms
78,236 KB
testcase_23 AC 107 ms
78,600 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