結果
問題 | No.184 たのしい排他的論理和(HARD) |
ユーザー |
👑 ![]() |
提出日時 | 2021-05-03 00:45:13 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 157 ms / 5,000 ms |
コード長 | 1,353 bytes |
コンパイル時間 | 307 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 96,768 KB |
最終ジャッジ日時 | 2024-07-21 09:55:25 |
合計ジャッジ時間 | 6,264 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
class XOR_Vector_Space:def __init__(self):self.S=[]def __contains__(self,x):for v in self.S:if x&v&(-v):x^=vif x==0:return Truereturn Falsedef __add__(self,other):W=XOR_Vector_Space()W.S=self.S[:]W.add_vector(*other.S)return Wdef add_vector(self,*T):for x in T:for v in self.S:if x&v&(-v):x^=vif x==0:breakif x:self.S.append(x)def dim(self):return len(self.S)def reduction(self):S=self.Sfor i in range(len(S)):vb=S[i]&(-S[i])for j in range(len(S)):if i==j: continueif 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 Falsereturn Truedef __ge__(self,other):return other<=selfdef __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()))