結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー 👑 KazunKazun
提出日時 2021-05-03 00:45:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 185 ms / 5,000 ms
コード長 1,353 bytes
コンパイル時間 833 ms
コンパイル使用メモリ 86,852 KB
実行使用メモリ 98,012 KB
最終ジャッジ日時 2023-09-28 15:14:24
合計ジャッジ時間 8,088 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,328 KB
testcase_01 AC 70 ms
71,136 KB
testcase_02 AC 70 ms
71,228 KB
testcase_03 AC 70 ms
71,000 KB
testcase_04 AC 70 ms
70,972 KB
testcase_05 AC 71 ms
71,132 KB
testcase_06 AC 69 ms
71,324 KB
testcase_07 AC 70 ms
71,296 KB
testcase_08 AC 153 ms
90,920 KB
testcase_09 AC 90 ms
76,728 KB
testcase_10 AC 130 ms
87,216 KB
testcase_11 AC 117 ms
83,280 KB
testcase_12 AC 167 ms
94,416 KB
testcase_13 AC 161 ms
93,084 KB
testcase_14 AC 122 ms
85,872 KB
testcase_15 AC 166 ms
94,236 KB
testcase_16 AC 152 ms
93,032 KB
testcase_17 AC 159 ms
94,736 KB
testcase_18 AC 74 ms
75,400 KB
testcase_19 AC 69 ms
71,244 KB
testcase_20 AC 92 ms
91,484 KB
testcase_21 AC 185 ms
98,012 KB
testcase_22 AC 182 ms
94,200 KB
testcase_23 AC 71 ms
71,272 KB
testcase_24 AC 70 ms
71,308 KB
testcase_25 AC 71 ms
71,072 KB
testcase_26 AC 71 ms
71,320 KB
testcase_27 AC 71 ms
71,244 KB
testcase_28 AC 135 ms
88,532 KB
testcase_29 AC 165 ms
92,692 KB
testcase_30 AC 147 ms
92,832 KB
testcase_31 AC 146 ms
90,488 KB
testcase_32 AC 158 ms
93,012 KB
testcase_33 AC 177 ms
94,412 KB
testcase_34 AC 168 ms
94,264 KB
testcase_35 AC 181 ms
94,112 KB
testcase_36 AC 169 ms
94,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class XOR_Vector_Space:
    def __init__(self):
        self.S=[]

    def __contains__(self,x):
        for v in self.S:
            if x&v&(-v):
                x^=v
            if x==0:
                return True
        return False

    def __add__(self,other):
        W=XOR_Vector_Space()

        W.S=self.S[:]
        W.add_vector(*other.S)
        return W

    def add_vector(self,*T):
        for x in T:
            for v in self.S:
                if x&v&(-v):
                    x^=v
                    if x==0:
                        break
            if x:
                self.S.append(x)

    def dim(self):
        return len(self.S)

    def reduction(self):
        S=self.S
        for i in range(len(S)):
            vb=S[i]&(-S[i])
            for j in  range(len(S)):
                if i==j: continue

                if S[j]&vb:
                    S[j]^=S[i]
        self.S=[s for s in S if s]

    def __le__(self,other):
        for u in self.S:
            if not u in other:
                return False
        return True

    def __ge__(self,other):
        return other<=self

    def __eq__(self,other):
        return (self<=other) and (other<=self)
#================================================
N=int(input())
A=list(map(int,input().split()))

V=XOR_Vector_Space()
V.add_vector(*A)

print(pow(2,V.dim()))
0