結果

問題 No.130 XOR Minimax
ユーザー kohei2019kohei2019
提出日時 2021-08-02 22:19:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 404 ms / 5,000 ms
コード長 446 bytes
コンパイル時間 1,885 ms
コンパイル使用メモリ 86,844 KB
実行使用メモリ 233,940 KB
最終ジャッジ日時 2023-10-14 20:55:30
合計ジャッジ時間 9,356 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 252 ms
86,120 KB
testcase_01 AC 76 ms
70,996 KB
testcase_02 AC 78 ms
71,000 KB
testcase_03 AC 76 ms
70,972 KB
testcase_04 AC 266 ms
233,940 KB
testcase_05 AC 295 ms
195,004 KB
testcase_06 AC 220 ms
152,656 KB
testcase_07 AC 239 ms
157,288 KB
testcase_08 AC 404 ms
104,480 KB
testcase_09 AC 140 ms
81,792 KB
testcase_10 AC 152 ms
86,048 KB
testcase_11 AC 242 ms
141,488 KB
testcase_12 AC 132 ms
79,588 KB
testcase_13 AC 217 ms
122,336 KB
testcase_14 AC 379 ms
100,040 KB
testcase_15 AC 111 ms
77,736 KB
testcase_16 AC 303 ms
91,516 KB
testcase_17 AC 313 ms
91,948 KB
testcase_18 AC 327 ms
93,852 KB
testcase_19 AC 361 ms
97,580 KB
testcase_20 AC 235 ms
85,676 KB
testcase_21 AC 370 ms
99,960 KB
testcase_22 AC 178 ms
79,848 KB
testcase_23 AC 137 ms
78,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def dfs(ls,p):
    if p < 0:
        return 0
    A = []
    B = []
    T = ls[:]
    for j in T:
        if (j >> p) % 2 == 0:
            A.append(j)
        else:
            B.append(j)
    ans = 0
    if (len(A) == 0) or (len(B) == 0):
        ans = dfs(T,p-1)
    else:
        ans = dfs(A,p-1)
        ans = min(ans,dfs(B,p-1))
        ans += 1 << p
    return ans

print(dfs(lsa,30))
0