結果

問題 No.130 XOR Minimax
ユーザー convexineqconvexineq
提出日時 2020-12-05 00:34:03
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 217 ms / 5,000 ms
コード長 405 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 87,224 KB
実行使用メモリ 147,208 KB
最終ジャッジ日時 2023-10-13 12:28:53
合計ジャッジ時間 6,015 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 145 ms
88,964 KB
testcase_01 AC 70 ms
70,948 KB
testcase_02 AC 69 ms
71,176 KB
testcase_03 AC 69 ms
71,200 KB
testcase_04 AC 83 ms
82,124 KB
testcase_05 AC 87 ms
84,860 KB
testcase_06 AC 205 ms
145,476 KB
testcase_07 AC 217 ms
147,208 KB
testcase_08 AC 162 ms
112,672 KB
testcase_09 AC 119 ms
79,932 KB
testcase_10 AC 130 ms
84,116 KB
testcase_11 AC 182 ms
109,108 KB
testcase_12 AC 112 ms
78,580 KB
testcase_13 AC 167 ms
106,468 KB
testcase_14 AC 188 ms
106,872 KB
testcase_15 AC 84 ms
75,948 KB
testcase_16 AC 164 ms
96,704 KB
testcase_17 AC 165 ms
97,348 KB
testcase_18 AC 173 ms
99,908 KB
testcase_19 AC 183 ms
103,948 KB
testcase_20 AC 141 ms
87,208 KB
testcase_21 AC 189 ms
107,360 KB
testcase_22 AC 123 ms
80,108 KB
testcase_23 AC 109 ms
78,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(a,i):
    if len(a) == 1:
        return 0
    b0 = []
    b1 = []
    for ai in a:
        if ai>>i&1: b1.append(ai)
        else: b0.append(ai)
    if not b0:
        return solve(b1,i-1)
    elif not b1:
        return solve(b0,i-1)
    else:
        return min(solve(b0,i-1),solve(b1,i-1)) + (1<<i)
    

n = int(input())
a = list(set(map(int,input().split())))
n = len(a)
print(solve(a,30))
0