結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
76,052 KB
testcase_01 AC 79 ms
75,948 KB
testcase_02 AC 83 ms
76,380 KB
testcase_03 AC 84 ms
76,264 KB
testcase_04 AC 83 ms
76,188 KB
testcase_05 AC 84 ms
76,268 KB
testcase_06 AC 83 ms
76,500 KB
testcase_07 AC 79 ms
75,952 KB
testcase_08 AC 75 ms
76,036 KB
testcase_09 AC 75 ms
75,908 KB
testcase_10 AC 82 ms
76,220 KB
testcase_11 AC 201 ms
78,328 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 141 ms
78,296 KB
testcase_15 AC 111 ms
77,016 KB
testcase_16 AC 124 ms
77,936 KB
testcase_17 AC 98 ms
76,232 KB
testcase_18 AC 189 ms
78,268 KB
testcase_19 AC 120 ms
78,892 KB
testcase_20 AC 117 ms
78,920 KB
testcase_21 AC 192 ms
78,684 KB
testcase_22 AC 113 ms
78,060 KB
testcase_23 AC 165 ms
77,964 KB
testcase_24 AC 171 ms
78,412 KB
testcase_25 AC 134 ms
78,236 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] += n_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