結果

問題 No.130 XOR Minimax
ユーザー nebukuro09nebukuro09
提出日時 2016-09-27 17:33:31
言語 Python2
(2.7.18)
結果
AC  
実行時間 919 ms / 5,000 ms
コード長 431 bytes
コンパイル時間 211 ms
コンパイル使用メモリ 6,672 KB
実行使用メモリ 35,252 KB
最終ジャッジ日時 2023-10-10 00:15:49
合計ジャッジ時間 11,093 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 412 ms
9,604 KB
testcase_01 AC 11 ms
6,128 KB
testcase_02 AC 10 ms
5,992 KB
testcase_03 AC 11 ms
6,060 KB
testcase_04 AC 323 ms
32,596 KB
testcase_05 AC 339 ms
35,252 KB
testcase_06 AC 397 ms
23,400 KB
testcase_07 AC 402 ms
23,740 KB
testcase_08 AC 919 ms
14,668 KB
testcase_09 AC 84 ms
8,924 KB
testcase_10 AC 125 ms
10,136 KB
testcase_11 AC 348 ms
20,972 KB
testcase_12 AC 43 ms
7,304 KB
testcase_13 AC 287 ms
18,036 KB
testcase_14 AC 775 ms
13,140 KB
testcase_15 AC 18 ms
6,328 KB
testcase_16 AC 553 ms
10,880 KB
testcase_17 AC 564 ms
10,964 KB
testcase_18 AC 631 ms
11,664 KB
testcase_19 AC 714 ms
12,696 KB
testcase_20 AC 357 ms
9,060 KB
testcase_21 AC 764 ms
13,168 KB
testcase_22 AC 175 ms
7,456 KB
testcase_23 AC 60 ms
6,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def rec(L, p):
    if p > 32 or len(L) == 0:
        return 0
    L0 = []
    L1 = []
    b = (1 << (32-p))
    for e in L:
        if e & b:
            L1.append(e)
        else:
            L0.append(e)
    if len(L0) == 0:
        return rec(L1, p+1)
    elif len(L1) == 0:
        return rec(L0, p+1)
    else:
        return b + min(rec(L0, p+1), rec(L1, p+1))

print rec(a, 0)
0