結果

問題 No.130 XOR Minimax
ユーザー warashi
提出日時 2015-02-09 17:47:06
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 827 bytes
コンパイル時間 205 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 26,612 KB
最終ジャッジ日時 2024-06-23 16:29:13
合計ジャッジ時間 6,307 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 2 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/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