結果

問題 No.130 XOR Minimax
ユーザー 👑 colognecologne
提出日時 2022-03-02 16:53:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 430 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 87,036 KB
実行使用メモリ 210,112 KB
最終ジャッジ日時 2023-09-23 09:19:26
合計ジャッジ時間 10,093 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 69 ms
71,196 KB
testcase_02 AC 69 ms
71,392 KB
testcase_03 AC 68 ms
71,404 KB
testcase_04 AC 219 ms
210,112 KB
testcase_05 AC 233 ms
158,280 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(A, b):
    if b == -1:
        return 0
    u = [a for a in A if not(a & (1 << b))]
    d = [a ^ (1 << b) for a in A if a & (1 << b)]

    if len(u) == 0:
        return solve(d, b-1)
    if len(d) == 0:
        return solve(u, b-1)
    return max(solve(d, b-1), solve(u, b-1)) + (1 << b)


def main():
    input()  # N
    *A, = map(int, input().split())
    print(solve(A, 29))


if __name__ == '__main__':
    main()
0