結果

問題 No.1689 Set Cards
ユーザー SidewaysOwlSidewaysOwl
提出日時 2021-09-25 14:45:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 197 ms / 2,000 ms
コード長 1,011 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 87,232 KB
実行使用メモリ 79,024 KB
最終ジャッジ日時 2023-09-18 23:02:20
合計ジャッジ時間 4,539 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
76,072 KB
testcase_01 AC 78 ms
76,120 KB
testcase_02 AC 82 ms
76,252 KB
testcase_03 AC 83 ms
76,476 KB
testcase_04 AC 81 ms
76,448 KB
testcase_05 AC 81 ms
76,444 KB
testcase_06 AC 81 ms
76,412 KB
testcase_07 AC 79 ms
76,184 KB
testcase_08 AC 74 ms
75,920 KB
testcase_09 AC 72 ms
75,956 KB
testcase_10 AC 79 ms
76,304 KB
testcase_11 AC 187 ms
78,332 KB
testcase_12 AC 197 ms
78,132 KB
testcase_13 AC 127 ms
78,288 KB
testcase_14 AC 140 ms
78,400 KB
testcase_15 AC 108 ms
77,204 KB
testcase_16 AC 124 ms
77,792 KB
testcase_17 AC 97 ms
76,452 KB
testcase_18 AC 187 ms
78,596 KB
testcase_19 AC 120 ms
78,860 KB
testcase_20 AC 121 ms
79,024 KB
testcase_21 AC 190 ms
78,536 KB
testcase_22 AC 112 ms
77,824 KB
testcase_23 AC 164 ms
77,964 KB
testcase_24 AC 173 ms
78,280 KB
testcase_25 AC 131 ms
78,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
n = int(input())

dp = [[0] * (1<<12) for _ in range(2)]
dp[0][0] = 1
for i in range(n):
    n_dp =  [[0] * (1<<12) for _ in range(2)]
    kc = list(map(int,input().split()))
    bit = 0
    for j in range(1,kc[0] + 1):
        bit += 1 << (kc[j]-1)
    for j in range(1 << 12):
        n_dp[0][j] += dp[0][j]
        n_dp[1][j] += dp[1][j]
        if j == 0:
            if bit != 0:
                n_dp[0][bit] += 1
                n_dp[0][bit] %= mod
            else:
                n_dp[1][0] += 1 
            n_dp[1][bit] += dp[1][0]
        else:
            if dp[0][j] > 0:
                if j & bit:
                    n_dp[0][j & bit] += dp[0][j]
                    n_dp[0][j & bit] %= mod
                else:
                    n_dp[1][j | bit] += dp[0][j]
                    n_dp[1][j | bit] %= mod
            if  dp[1][j] > 0:
                n_dp[1][j | bit] += dp[1][j]
                n_dp[1][j | bit] %= mod
#     print(n_dp[0])
    dp = n_dp
print(sum(dp[1]) % mod)
0