結果

問題 No.130 XOR Minimax
ユーザー titiatitia
提出日時 2022-02-21 01:11:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 696 ms / 5,000 ms
コード長 396 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 10,768 KB
実行使用メモリ 39,856 KB
最終ジャッジ日時 2023-09-11 21:13:46
合計ジャッジ時間 8,999 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 322 ms
14,332 KB
testcase_01 AC 16 ms
7,784 KB
testcase_02 AC 16 ms
7,832 KB
testcase_03 AC 15 ms
7,768 KB
testcase_04 AC 338 ms
34,640 KB
testcase_05 AC 346 ms
39,856 KB
testcase_06 AC 403 ms
28,480 KB
testcase_07 AC 380 ms
28,160 KB
testcase_08 AC 696 ms
19,120 KB
testcase_09 AC 78 ms
11,652 KB
testcase_10 AC 108 ms
13,784 KB
testcase_11 AC 327 ms
25,824 KB
testcase_12 AC 46 ms
9,816 KB
testcase_13 AC 267 ms
22,444 KB
testcase_14 AC 596 ms
17,376 KB
testcase_15 AC 21 ms
8,200 KB
testcase_16 AC 429 ms
15,336 KB
testcase_17 AC 444 ms
15,892 KB
testcase_18 AC 476 ms
15,468 KB
testcase_19 AC 575 ms
16,732 KB
testcase_20 AC 288 ms
13,532 KB
testcase_21 AC 588 ms
17,104 KB
testcase_22 AC 143 ms
10,284 KB
testcase_23 AC 53 ms
8,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def calc(c,A):
    if c<0:
        return 0
    
    X=[]
    Y=[]

    for a in A:
        if a & (1<<c) != 0:
            X.append(a)
        else:
            Y.append(a)

    if len(X)==0:
        return calc(c-1,Y)
    elif len(Y)==0:
        return calc(c-1,X)
    else:
        return (1<<c)+min(calc(c-1,X),calc(c-1,Y))

print(calc(32,A))
0