結果

問題 No.130 XOR Minimax
コンテスト
ユーザー warashi
提出日時 2015-02-09 17:47:06
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 827 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 602 ms
コンパイル使用メモリ 20,828 KB
実行使用メモリ 30,232 KB
最終ジャッジ日時 2026-03-08 17:18:34
合計ジャッジ時間 7,825 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 2 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#!/usr/bin/env python3
from functools import partial
from itertools import takewhile


def equal(list, index):
    return len([0 for x in list if x[index] != list[0][index]]) == 0


def bit_invert(string):
    def _inv(s):
        if s == '0':
            return '1'
        return '0'
    return ''.join([_inv(s) for s in string])


def bit_fill(string, length):
    need = length - len(string)
    return '0' * (need) + string


def bool_bin_to_int(bool_list):
    def _bool2int(b):
        if b:
            return '1'
        return '0'
    return int(''.join([_bool2int(b) for b in bool_list]), 2)

N = int(input())
A = [format(int(x), "b") for x in input().split()]
max_len_A = max([len(a) for a in A])
A = [bit_fill(a, max_len_A) for a in A]
neq = [not equal(A, i) for i in range(max_len_A)]
print(bool_bin_to_int(neq))
0