結果
問題 | No.2895 Zero XOR Subset |
ユーザー |
![]() |
提出日時 | 2024-09-20 21:36:09 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,598 bytes |
コンパイル時間 | 146 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 106,944 KB |
最終ジャッジ日時 | 2024-09-20 21:36:20 |
合計ジャッジ時間 | 7,333 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 14 WA * 21 |
ソースコード
class xor_base():def __init__(self):self.K = 60self._list = [0] * self.Kself.cnt = 0def min_all(self, x):for i in range(self.K - 1, -1, -1):if (x >> i) & 1:x ^= self._list[i]return xdef add(self, x):x = self.min_all(x)if x == 0:returnfor 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] ^= xself._list[i] = xself.cnt += 1return 1return 0def get(self, x):now = 0for i in range(self.K):if self._list[i] == 0:continueif x & 1:now ^= self._list[i]x >>= 1return nowdef __len__(self):return self.cntdef __str__(self):return f"{self._list}, len = {self.cnt}"N = int(input())A = list(map(int, input().split()))X = xor_base()L = []now = -1ans = []for i, a in enumerate(A):if a == 0:print(1)print(i + 1)exit()if not X.add(a):now = aans.append(i+1)breakelse:L.append((A[i], i))L.sort(reverse=True)for a, i in L:if a ^ now < now:ans.append(i + 1)now ^= aans.sort()if now == 0:print(len(ans))for a in ans:print(a)else:print(-1)