結果

問題 No.130 XOR Minimax
ユーザー ああいいああいい
提出日時 2022-03-30 17:49:36
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 334 ms / 5,000 ms
コード長 462 bytes
コンパイル時間 1,326 ms
コンパイル使用メモリ 87,196 KB
実行使用メモリ 211,568 KB
最終ジャッジ日時 2023-08-09 12:48:05
合計ジャッジ時間 7,237 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 230 ms
85,252 KB
testcase_01 AC 69 ms
71,132 KB
testcase_02 AC 71 ms
71,216 KB
testcase_03 AC 70 ms
71,288 KB
testcase_04 AC 222 ms
211,568 KB
testcase_05 AC 216 ms
174,072 KB
testcase_06 AC 195 ms
138,868 KB
testcase_07 AC 211 ms
146,696 KB
testcase_08 AC 334 ms
102,840 KB
testcase_09 AC 127 ms
80,528 KB
testcase_10 AC 135 ms
84,408 KB
testcase_11 AC 214 ms
130,068 KB
testcase_12 AC 121 ms
79,180 KB
testcase_13 AC 210 ms
113,876 KB
testcase_14 AC 325 ms
98,344 KB
testcase_15 AC 100 ms
77,584 KB
testcase_16 AC 262 ms
90,448 KB
testcase_17 AC 277 ms
90,860 KB
testcase_18 AC 284 ms
93,368 KB
testcase_19 AC 291 ms
96,772 KB
testcase_20 AC 211 ms
84,488 KB
testcase_21 AC 333 ms
98,324 KB
testcase_22 AC 157 ms
79,504 KB
testcase_23 AC 121 ms
78,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
a = list(map(int,input().split()))

def calc(now,l,b):
    if b == -1:
        return now
    one = []
    zero = []
    mask = 1 << b
    for i in l:
        if i & mask:
            one.append(i)
        else:
            zero.append(i)
    if len(one) == 0 or len(zero) == 0:
        return calc(now,l,b-1)
    else:
        t1 = calc(now | mask,one,b-1)
        t2 = calc(now | mask,zero,b - 1)
        return min(t1,t2)
print(calc(0,a,30))
0