結果

問題 No.130 XOR Minimax
ユーザー ああいいああいい
提出日時 2022-03-30 17:49:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 324 ms / 5,000 ms
コード長 462 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 82,420 KB
実行使用メモリ 217,284 KB
最終ジャッジ日時 2024-04-27 07:50:19
合計ジャッジ時間 5,423 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 189 ms
84,436 KB
testcase_01 AC 38 ms
53,940 KB
testcase_02 AC 40 ms
53,800 KB
testcase_03 AC 37 ms
53,364 KB
testcase_04 AC 196 ms
217,284 KB
testcase_05 AC 191 ms
178,040 KB
testcase_06 AC 175 ms
132,416 KB
testcase_07 AC 183 ms
146,344 KB
testcase_08 AC 324 ms
102,796 KB
testcase_09 AC 97 ms
78,236 KB
testcase_10 AC 107 ms
84,272 KB
testcase_11 AC 186 ms
129,240 KB
testcase_12 AC 87 ms
77,040 KB
testcase_13 AC 177 ms
119,848 KB
testcase_14 AC 300 ms
98,004 KB
testcase_15 AC 70 ms
76,424 KB
testcase_16 AC 226 ms
89,628 KB
testcase_17 AC 235 ms
90,156 KB
testcase_18 AC 258 ms
92,300 KB
testcase_19 AC 279 ms
96,000 KB
testcase_20 AC 180 ms
83,712 KB
testcase_21 AC 293 ms
98,092 KB
testcase_22 AC 125 ms
77,604 KB
testcase_23 AC 92 ms
76,448 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