結果

問題 No.1689 Set Cards
コンテスト
ユーザー ああいい
提出日時 2022-03-04 10:42:19
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 500 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 191 ms
コンパイル使用メモリ 85,452 KB
実行使用メモリ 157,192 KB
最終ジャッジ日時 2026-04-01 23:54:14
合計ジャッジ時間 2,513 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N = int(input())

dat = [0] * (1 << 12)
for _ in range(N):
    k,*l = map(int,input().split())
    bit = 0
    for i in l:
        bit |= 1 << (i-1)
    dat[bit] += 1
P = 998244353
for i in range(12):
    for bit in range(1 << 12):
        if bit & (1 << i):
            dat[bit ^ (1 << i)] += dat[bit]
ans = pow(2,N,P)-1
for bit in range(1,1 << 12):
    if bin(bit).count('1') % 2 == 0:
        c = 1
    else:
        c = -1
    tmp = pow(2,dat[bit],P) - 1
    ans = (ans + c * tmp) % P
print(ans)
0