結果

問題 No.1421 国勢調査 (Hard)
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-03-06 13:55:16
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 809 bytes
コンパイル時間 401 ms
コンパイル使用メモリ 87,212 KB
実行使用メモリ 78,416 KB
最終ジャッジ日時 2023-07-30 00:38:12
合計ジャッジ時間 7,307 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,596 KB
testcase_01 AC 71 ms
71,580 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 72 ms
71,480 KB
testcase_13 AC 73 ms
71,296 KB
testcase_14 AC 73 ms
71,100 KB
testcase_15 AC 78 ms
71,296 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 78 ms
71,304 KB
testcase_20 AC 72 ms
71,420 KB
testcase_21 WA -
testcase_22 AC 144 ms
78,416 KB
testcase_23 AC 144 ms
78,116 KB
testcase_24 AC 143 ms
78,404 KB
testcase_25 AC 142 ms
78,028 KB
testcase_26 AC 140 ms
78,096 KB
testcase_27 AC 141 ms
78,004 KB
testcase_28 AC 143 ms
77,908 KB
testcase_29 AC 145 ms
77,932 KB
testcase_30 AC 140 ms
78,040 KB
testcase_31 AC 141 ms
77,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
l = max(n,m)+5
C = [0]*l
Y = [0]*l
for i in range(m):
    a = int(input())
    B = list(map(int,input().split()))
    y = int(input())
    Y[i] = 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