結果

問題 No.130 XOR Minimax
ユーザー nebukuro09nebukuro09
提出日時 2016-09-27 17:32:49
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 377 ms / 5,000 ms
コード長 431 bytes
コンパイル時間 428 ms
コンパイル使用メモリ 77,588 KB
実行使用メモリ 195,112 KB
最終ジャッジ日時 2023-10-10 00:15:10
合計ジャッジ時間 7,228 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 240 ms
92,328 KB
testcase_01 AC 75 ms
76,272 KB
testcase_02 AC 77 ms
76,136 KB
testcase_03 AC 75 ms
76,120 KB
testcase_04 AC 230 ms
195,112 KB
testcase_05 AC 214 ms
182,108 KB
testcase_06 AC 219 ms
186,948 KB
testcase_07 AC 213 ms
144,396 KB
testcase_08 AC 377 ms
117,680 KB
testcase_09 AC 136 ms
83,492 KB
testcase_10 AC 152 ms
91,952 KB
testcase_11 AC 245 ms
172,104 KB
testcase_12 AC 130 ms
81,676 KB
testcase_13 AC 218 ms
148,420 KB
testcase_14 AC 356 ms
111,744 KB
testcase_15 AC 108 ms
79,268 KB
testcase_16 AC 279 ms
99,600 KB
testcase_17 AC 294 ms
100,116 KB
testcase_18 AC 313 ms
102,928 KB
testcase_19 AC 341 ms
107,924 KB
testcase_20 AC 219 ms
90,256 KB
testcase_21 AC 357 ms
111,556 KB
testcase_22 AC 172 ms
82,740 KB
testcase_23 AC 137 ms
81,204 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