結果

問題 No.130 XOR Minimax
ユーザー lllllll88938494lllllll88938494
提出日時 2023-05-09 10:32:24
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 665 bytes
コンパイル時間 1,205 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 265,268 KB
最終ジャッジ日時 2023-08-17 04:40:31
合計ジャッジ時間 13,576 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**6)
n = int(input())
a = list(map(int,input().split()))

c=[[0,0] for i in range(31)]
for i in a:
    t=bin(i)[2:][::-1]
    for j in range(len(t)):
        c[j][int(t[j])] += 1

cnt = 0
for i,j in c:
    if i + j == 0:
        break
    cnt+=1

lis=[]
def  cal(x,ind):
    if ind == cnt:
        lis.append(int(x[::-1],2))
        return
    o,i=c[ind][0],c[ind][1]
    
    if o == n:
        cal(x+'0',ind+1)
    elif i == n:
        cal(x+'1',ind+1)
    else:
        cal(x+'0',ind+1)
        cal(x+'1',ind+1)
        
cal('',0)
A=10**18
for x in lis:
    t=0
    for i in a:
        t=max(i^x,t)
    A=min(A,t)
    
print(A)
0