結果

問題 No.1689 Set Cards
ユーザー brthyyjpbrthyyjp
提出日時 2021-09-24 22:52:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 1,123 bytes
コンパイル時間 989 ms
コンパイル使用メモリ 86,796 KB
実行使用メモリ 77,816 KB
最終ジャッジ日時 2023-09-18 21:56:57
合計ジャッジ時間 4,530 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
75,936 KB
testcase_01 AC 80 ms
75,828 KB
testcase_02 AC 83 ms
75,744 KB
testcase_03 AC 83 ms
75,912 KB
testcase_04 AC 84 ms
75,920 KB
testcase_05 AC 84 ms
75,728 KB
testcase_06 AC 83 ms
75,984 KB
testcase_07 AC 83 ms
75,872 KB
testcase_08 AC 81 ms
75,912 KB
testcase_09 AC 81 ms
75,828 KB
testcase_10 AC 83 ms
75,744 KB
testcase_11 AC 141 ms
77,588 KB
testcase_12 AC 140 ms
77,452 KB
testcase_13 AC 139 ms
77,428 KB
testcase_14 AC 143 ms
77,652 KB
testcase_15 AC 96 ms
76,332 KB
testcase_16 AC 124 ms
77,460 KB
testcase_17 AC 92 ms
75,904 KB
testcase_18 AC 142 ms
77,816 KB
testcase_19 AC 144 ms
77,712 KB
testcase_20 AC 140 ms
77,368 KB
testcase_21 AC 133 ms
77,156 KB
testcase_22 AC 132 ms
77,164 KB
testcase_23 AC 132 ms
76,932 KB
testcase_24 AC 135 ms
77,644 KB
testcase_25 AC 138 ms
77,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

mod = 998244353

def main():

    n = int(input())
    C = []
    for i in range(n):
        temp = list(map(int, input().split()))
        temp = temp[1:]
        if temp:
            temp = [i-1 for i in temp]
        v = 0
        for i in temp:
            v |= (1<<i)
        C.append(v)
    #print(C)
    dp = [[0]*(1<<12) for i in range(2)]
    dp[0][0] = 1
    for i in range(n):
        nx = [[0]*(1<<12) for i in range(2)]
        for j in range(2):
            for s in range(1<<12):
                nx[j][s] = dp[j][s]
        v = C[i]
        for j in range(2):
            for s in range(1<<12):
                if j == 0:
                    if s == 0:
                        nx[j+1][s|v] += dp[j][s]
                        nx[j+1][s|v] %= mod
                    else:
                        break
                else:
                    nx[j][s&v] += dp[j][s]
                    nx[j][s&v] %= mod
        dp = nx
    ans = 0
    ans += dp[1][0]
    ans %= mod
    print(ans)

if __name__ == '__main__':
    main()
0