結果

問題 No.130 XOR Minimax
ユーザー ああいいああいい
提出日時 2022-03-30 17:33:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 813 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 82,364 KB
実行使用メモリ 90,968 KB
最終ジャッジ日時 2024-04-27 07:33:47
合計ジャッジ時間 6,178 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 39 ms
53,944 KB
testcase_02 AC 44 ms
58,624 KB
testcase_03 AC 46 ms
61,212 KB
testcase_04 AC 886 ms
88,472 KB
testcase_05 AC 993 ms
90,968 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

b = 30
def calc(k):
    x = [-1] * (b+1)
    for u in a:
        for j in range(b,-1,-1):
            mask = 1 << j
            if k & mask == 0 and u & mask:
                if x[j] == 0:return False
                elif x[j] == -1:
                    x[j] = 1
            elif k & mask == 0 and u & mask == 0:
                if x[j] == 1:return False
                elif x[j] == -1:
                    x[j] = 0
            elif k & mask:
                if x[j] == 1 and u & mask:
                    break
                if x[j] == 0 and u & mask == 0:
                    break
    return True
end = (1 << b) - 1
start = -1
while end - start > 1:
    mid = end + start >> 1
    if calc(mid):
        end = mid
    else:
        start = mid
print(end)
0