結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー None
提出日時 2021-06-02 23:15:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 147 ms / 5,000 ms
コード長 905 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 92,032 KB
最終ジャッジ日時 2024-11-15 18:57:29
合計ジャッジ時間 6,643 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

def Gauss2(mat):
    """
    F_2 用
    :param mat: [bit1,bit2,...]
    :return: rank, gaussの標準形
    """
    H,W=len(mat),max(mat).bit_length()
    res=[mat[i] for i in range(H)]
    rank = 0
    for w in range(W):
        pivot = -1
        for h in range(rank,H):
            if res[h] & (1<<w):
                pivot = h
                break
        else:
            continue
        res[rank],res[pivot] =res[pivot],res[rank]
        for h in range(H):
            if h == rank: continue
            if not (res[h]&(1<<w)):
                continue
            res[h] ^= res[rank]
        rank += 1
    return rank, res

def bit_rep(bit,N):
    return format(bit, "0" + str(N) + "b")

############################################################################
import sys
input = sys.stdin.readline


N=int(input())
A=list(map(int, input().split()))
rank,gauss=Gauss2(A)
print(pow(2,rank))
0