結果

問題 No.1421 国勢調査 (Hard)
コンテスト
ユーザー 👑 potato167
提出日時 2022-02-17 01:58:02
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 579 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 220 ms
コンパイル使用メモリ 84,968 KB
実行使用メモリ 81,512 KB
最終ジャッジ日時 2026-03-18 17:59:44
合計ジャッジ時間 3,236 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N,M=map(int,input().split())
table=[(0,0)]*0
J=0
for i in range(M):
	A=int(input())
	D=0
	tmp=list(map(int,input().split()))
	for j in range(A):
		D+=(1<<(tmp[j]-1))
	Y=int(input())
	for j in range(len(table)):
		if (D^table[j][0])<D:
			D^=table[j][0]
			Y^=table[j][1]
	if D!=0:
		table.append((D,Y))
	elif Y!=0:
		J=1
if J==1:
	print(-1)
	exit()
ans=[0]*N
table.sort()
for i in range(len(table)):
	tmp=0
	ind=0
	for j in range(N):
		if (table[i][0]&(1<<j))!=0:
			ind=j
			tmp^=ans[j]
	ans[ind]=(tmp^table[i][1])
	#print(ind,tmp,table[i],ans)
for i in range(N):
	print(ans[i])
0