結果

問題 No.1689 Set Cards
ユーザー SidewaysOwlSidewaysOwl
提出日時 2021-09-25 14:35:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 985 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 77,684 KB
最終ジャッジ日時 2024-07-05 12:05:21
合計ジャッジ時間 2,940 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
61,256 KB
testcase_01 AC 41 ms
60,780 KB
testcase_02 AC 45 ms
64,624 KB
testcase_03 AC 45 ms
63,636 KB
testcase_04 AC 46 ms
63,312 KB
testcase_05 AC 45 ms
63,528 KB
testcase_06 AC 44 ms
64,816 KB
testcase_07 AC 39 ms
61,696 KB
testcase_08 AC 38 ms
59,688 KB
testcase_09 AC 37 ms
60,420 KB
testcase_10 AC 44 ms
63,112 KB
testcase_11 AC 138 ms
77,236 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 101 ms
76,852 KB
testcase_15 AC 73 ms
76,012 KB
testcase_16 AC 85 ms
76,800 KB
testcase_17 AC 60 ms
71,808 KB
testcase_18 AC 138 ms
76,728 KB
testcase_19 AC 79 ms
77,544 KB
testcase_20 AC 80 ms
76,928 KB
testcase_21 AC 141 ms
77,620 KB
testcase_22 AC 77 ms
76,732 KB
testcase_23 AC 119 ms
77,164 KB
testcase_24 AC 124 ms
77,684 KB
testcase_25 AC 91 ms
77,184 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