結果
| 問題 |
No.2895 Zero XOR Subset
|
| コンテスト | |
| ユーザー |
detteiuu
|
| 提出日時 | 2024-09-21 00:48:18 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,026 bytes |
| コンパイル時間 | 197 ms |
| コンパイル使用メモリ | 82,328 KB |
| 実行使用メモリ | 306,260 KB |
| 最終ジャッジ日時 | 2024-09-21 00:48:24 |
| 合計ジャッジ時間 | 4,501 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | TLE * 1 -- * 34 |
ソースコード
from collections import deque
N = int(input())
A = list(map(int, input().split()))
B = [[0]*60 for _ in range(N)]
for i in range(N):
for j in range(60):
if 1<<j & A[i]:
B[i][59-j] = 1
row = 0
idx = list(range(N))
ans = []
G = [[] for _ in range(N)]
for j in range(60):
pivot = row
while pivot < N and B[pivot][j] == 0:
pivot += 1
if pivot == N:
continue
B[row], B[pivot] = B[pivot], B[row]
idx[row], idx[pivot] = idx[pivot], idx[row]
for i in range(row+1, N):
if i != row and B[i][j] == 1:
G[i].append(row)
for k in range(60):
B[i][k] ^= B[row][k]
row += 1
if max(B[-1]) == 0:
que = deque()
que.append(i)
ans = set([idx[-1]+1])
while que:
n = que.popleft()
for v in G[n]:
if idx[v]+1 in ans:
ans.remove(idx[v]+1)
else:
ans.add(idx[v]+1)
que.append(v)
print(len(ans))
print(*ans)
else:
print(-1)
detteiuu