結果

問題 No.1421 国勢調査 (Hard)
ユーザー 👑 potato167potato167
提出日時 2022-02-17 01:58:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 166 ms / 2,000 ms
コード長 579 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 86,916 KB
実行使用メモリ 78,812 KB
最終ジャッジ日時 2023-09-11 17:21:41
合計ジャッジ時間 6,326 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,128 KB
testcase_01 AC 74 ms
71,184 KB
testcase_02 AC 78 ms
71,384 KB
testcase_03 AC 74 ms
71,348 KB
testcase_04 AC 74 ms
71,204 KB
testcase_05 AC 76 ms
71,284 KB
testcase_06 AC 73 ms
70,916 KB
testcase_07 AC 74 ms
71,148 KB
testcase_08 AC 73 ms
71,356 KB
testcase_09 AC 75 ms
71,476 KB
testcase_10 AC 74 ms
71,324 KB
testcase_11 AC 75 ms
71,276 KB
testcase_12 AC 73 ms
71,248 KB
testcase_13 AC 73 ms
71,228 KB
testcase_14 AC 74 ms
71,084 KB
testcase_15 AC 72 ms
70,908 KB
testcase_16 AC 74 ms
71,272 KB
testcase_17 AC 74 ms
71,404 KB
testcase_18 AC 72 ms
71,320 KB
testcase_19 AC 73 ms
70,916 KB
testcase_20 AC 74 ms
71,192 KB
testcase_21 AC 73 ms
71,412 KB
testcase_22 AC 142 ms
77,404 KB
testcase_23 AC 141 ms
77,684 KB
testcase_24 AC 139 ms
77,452 KB
testcase_25 AC 140 ms
77,556 KB
testcase_26 AC 143 ms
77,344 KB
testcase_27 AC 147 ms
77,504 KB
testcase_28 AC 166 ms
77,920 KB
testcase_29 AC 166 ms
77,764 KB
testcase_30 AC 166 ms
78,812 KB
testcase_31 AC 165 ms
77,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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