結果

問題 No.1689 Set Cards
ユーザー SidewaysOwlSidewaysOwl
提出日時 2021-09-25 14:35:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 985 bytes
コンパイル時間 351 ms
コンパイル使用メモリ 87,268 KB
実行使用メモリ 79,044 KB
最終ジャッジ日時 2023-09-18 23:01:56
合計ジャッジ時間 4,614 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
76,156 KB
testcase_01 AC 76 ms
76,024 KB
testcase_02 AC 82 ms
76,436 KB
testcase_03 AC 80 ms
76,300 KB
testcase_04 AC 82 ms
76,392 KB
testcase_05 AC 82 ms
76,200 KB
testcase_06 AC 81 ms
76,508 KB
testcase_07 AC 76 ms
75,824 KB
testcase_08 AC 75 ms
76,040 KB
testcase_09 AC 72 ms
76,060 KB
testcase_10 AC 81 ms
76,244 KB
testcase_11 AC 189 ms
78,492 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 142 ms
78,332 KB
testcase_15 AC 110 ms
77,328 KB
testcase_16 AC 125 ms
77,824 KB
testcase_17 AC 95 ms
76,456 KB
testcase_18 AC 186 ms
78,608 KB
testcase_19 AC 120 ms
78,920 KB
testcase_20 AC 119 ms
78,800 KB
testcase_21 AC 192 ms
79,044 KB
testcase_22 AC 112 ms
77,792 KB
testcase_23 AC 159 ms
78,024 KB
testcase_24 AC 170 ms
78,464 KB
testcase_25 AC 129 ms
78,156 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] += dp[1][0] + 1 
        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