結果

問題 No.130 XOR Minimax
ユーザー 👑 colognecologne
提出日時 2022-03-02 16:55:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 646 ms / 5,000 ms
コード長 430 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 87,220 KB
実行使用メモリ 210,236 KB
最終ジャッジ日時 2023-09-23 09:21:43
合計ジャッジ時間 9,184 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 351 ms
84,028 KB
testcase_01 AC 70 ms
71,136 KB
testcase_02 AC 70 ms
71,580 KB
testcase_03 AC 69 ms
71,412 KB
testcase_04 AC 229 ms
210,236 KB
testcase_05 AC 234 ms
158,280 KB
testcase_06 AC 242 ms
143,412 KB
testcase_07 AC 265 ms
148,856 KB
testcase_08 AC 646 ms
96,888 KB
testcase_09 AC 152 ms
79,900 KB
testcase_10 AC 143 ms
84,308 KB
testcase_11 AC 283 ms
128,912 KB
testcase_12 AC 179 ms
79,552 KB
testcase_13 AC 221 ms
112,344 KB
testcase_14 AC 592 ms
95,320 KB
testcase_15 AC 106 ms
77,192 KB
testcase_16 AC 492 ms
88,356 KB
testcase_17 AC 441 ms
88,780 KB
testcase_18 AC 524 ms
90,784 KB
testcase_19 AC 617 ms
94,056 KB
testcase_20 AC 331 ms
83,344 KB
testcase_21 AC 566 ms
94,916 KB
testcase_22 AC 232 ms
79,916 KB
testcase_23 AC 137 ms
78,048 KB
権限があれば一括ダウンロードができます

ソースコード

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 min(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