結果

問題 No.1421 国勢調査 (Hard)
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-03-06 13:50:17
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 794 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 76,928 KB
最終ジャッジ日時 2024-04-17 02:40:41
合計ジャッジ時間 6,619 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,096 KB
testcase_01 AC 42 ms
52,096 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 42 ms
52,352 KB
testcase_13 AC 43 ms
52,352 KB
testcase_14 AC 42 ms
52,352 KB
testcase_15 AC 43 ms
52,352 KB
testcase_16 RE -
testcase_17 WA -
testcase_18 RE -
testcase_19 AC 43 ms
52,480 KB
testcase_20 AC 43 ms
52,224 KB
testcase_21 WA -
testcase_22 AC 120 ms
76,928 KB
testcase_23 AC 120 ms
76,672 KB
testcase_24 AC 123 ms
76,672 KB
testcase_25 AC 122 ms
76,928 KB
testcase_26 AC 128 ms
76,800 KB
testcase_27 AC 122 ms
76,672 KB
testcase_28 AC 123 ms
76,800 KB
testcase_29 AC 124 ms
76,672 KB
testcase_30 AC 121 ms
76,672 KB
testcase_31 AC 122 ms
76,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
C = [0]*m
Y = []
for i in range(m):
    a = int(input())
    B = list(map(int,input().split()))
    y = int(input())
    Y.append(y)
    for b in B:
        C[i] |= 1<<(b-1)


rank = 0
for i in range(n,-1,-1):
    for j in range(rank+1,m):
        if C[j] & 1 << i:
            C[rank],C[j] = C[j],C[rank]
            Y[rank],Y[j] = Y[j],Y[rank]
            break

    if not (C[rank] & 1 << i):
        continue
    for j in range(m):
        if j != rank and C[j] & 1<<i:
            C[j] ^= C[rank]
            Y[j] ^= Y[rank]
    rank += 1

for i in range(rank,m):
    if Y[i]:
        print(-1)
        exit()
ans = [0]*n
for i in range(rank):
    for j in range(n):
        if C[i] >> j & 1:
            ans[j] = Y[i]
            break
print(*ans,sep="\n")
0