結果

問題 No.130 XOR Minimax
ユーザー rpy3cpprpy3cpp
提出日時 2015-07-10 10:52:14
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 658 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 11,012 KB
実行使用メモリ 21,292 KB
最終ジャッジ日時 2023-09-22 09:48:26
合計ジャッジ時間 2,309 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 16 ms
8,200 KB
testcase_02 AC 17 ms
8,200 KB
testcase_03 AC 16 ms
8,048 KB
testcase_04 AC 34 ms
10,136 KB
testcase_05 AC 50 ms
18,896 KB
testcase_06 AC 112 ms
21,048 KB
testcase_07 RE -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 RE -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 WA -
testcase_20 RE -
testcase_21 WA -
testcase_22 RE -
testcase_23 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect

def read_data():
    N = int(input())
    As = list(map(int, input().split()))
    return N, As

def solve(N, As):
    As = list(set(As))
    As.sort()
    maxA = As[-1]
    if maxA == 0:
        return 0
    idx = 1 << (len(bin(maxA)) - 3)
    return divq(As, idx, 0, len(As))

def divq(As, idx, begin, end):
    if idx == 0:
        return 0
    new_idx = idx >> 1
    if not(As[end-1] & idx) or As[begin] & idx:
        return divq(As, new_idx, begin, end)
    mid = bisect.bisect_left(As, As[begin] + idx, begin, end)
    return idx + min(divq(As, new_idx, begin, mid), divq(As, new_idx, mid, end))

N, As = read_data()
print(solve(N, As))
0