結果
| 問題 |
No.2895 Zero XOR Subset
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2024-09-20 22:30:15 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 114 ms / 2,000 ms |
| コード長 | 876 bytes |
| コンパイル時間 | 152 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 33,052 KB |
| 最終ジャッジ日時 | 2024-09-20 22:30:21 |
| 合計ジャッジ時間 | 4,440 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 35 |
ソースコード
import sys
input = sys.stdin.readline
N=int(input())
A=list(map(int,input().split()))
# xorの掃き出し法・基底
BASE=[]
def sweep(x):
LIST=[]
for b,LI in BASE:
if b^x<x:
x=b^x
LIST+=LI
LIST.sort()
LIST2=[]
for l in LIST:
if LIST2 and LIST2[-1]==l:
LIST2.pop()
else:
LIST2.append(l)
return x,LIST2
for i in range(N):
x=A[i]
k=sweep(x)
if k[0]!=0: # 掃き出した値が0でないなら基底に入れる。
BASE.append((k[0],k[1]+[i]))
else:
ANS=k[1]+[i]
ANS.sort()
LA=[]
for ans in ANS:
if LA and LA[-1]==ans:
LA.pop()
else:
LA.append(ans)
print(len(ANS))
for ans in ANS:
print(ans+1)
break
else:
print(-1)
titia