結果
問題 | No.1421 国勢調査 (Hard) |
ユーザー | 👑 potato167 |
提出日時 | 2022-02-17 01:58:02 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 140 ms / 2,000 ms |
コード長 | 579 bytes |
コンパイル時間 | 242 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 77,016 KB |
最終ジャッジ日時 | 2024-06-29 07:24:56 |
合計ジャッジ時間 | 4,582 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
ソースコード
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])