結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー rlangevinrlangevin
提出日時 2023-07-17 15:29:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 53 ms / 5,000 ms
コード長 1,104 bytes
コンパイル時間 538 ms
コンパイル使用メモリ 81,764 KB
実行使用メモリ 66,388 KB
最終ジャッジ日時 2023-10-18 00:25:01
合計ジャッジ時間 2,842 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,448 KB
testcase_01 AC 38 ms
53,448 KB
testcase_02 AC 39 ms
53,448 KB
testcase_03 AC 39 ms
53,448 KB
testcase_04 AC 38 ms
53,448 KB
testcase_05 AC 38 ms
53,448 KB
testcase_06 AC 38 ms
53,448 KB
testcase_07 AC 53 ms
66,332 KB
testcase_08 AC 51 ms
66,388 KB
testcase_09 AC 51 ms
64,340 KB
testcase_10 AC 51 ms
66,388 KB
testcase_11 AC 52 ms
66,388 KB
testcase_12 AC 38 ms
53,464 KB
testcase_13 AC 38 ms
53,464 KB
testcase_14 AC 51 ms
66,388 KB
testcase_15 AC 52 ms
66,388 KB
testcase_16 AC 39 ms
53,464 KB
testcase_17 AC 49 ms
62,292 KB
testcase_18 AC 52 ms
66,388 KB
testcase_19 AC 45 ms
59,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class xor_base():
    def __init__(self):
        self.K = 60
        self._list = [0] * self.K
        self.cnt = 0
        
    def min_all(self, x):
        for i in range(self.K - 1, -1, -1):
            if (x >> i) & 1:
                x ^= self._list[i]
        return x
    
    def add(self, x):
        x = self.min_all(x)
        if x == 0:
            return 
        for i in range(self.K - 1, -1, -1):
            if (x >> i) & 1:
                for j in range(self.K):
                    if (self._list[j] >> i) & 1:
                        self._list[j] ^= x
                self._list[i] = x
                self.cnt += 1
                return
            
    def get(self, x):
        now = 0
        for i in range(self.K):
            if (x >> i) & 1:
                now ^= self._list[i]
        return now
    
    def __len__(self):
        return self.cnt              
        
    def __str__(self):
        return f"{self._list}, len = {self.cnt}"
    
    

N = int(input())
A = list(map(int, input().split()))

B = xor_base()
for a in A:
    B.add(a)
    
print(2**len(B))
0