結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
76,172 KB
testcase_01 AC 81 ms
75,904 KB
testcase_02 AC 85 ms
76,312 KB
testcase_03 AC 87 ms
76,248 KB
testcase_04 AC 84 ms
76,448 KB
testcase_05 AC 84 ms
76,432 KB
testcase_06 AC 83 ms
76,180 KB
testcase_07 AC 79 ms
75,968 KB
testcase_08 AC 76 ms
76,056 KB
testcase_09 AC 75 ms
76,196 KB
testcase_10 AC 83 ms
76,256 KB
testcase_11 AC 192 ms
78,324 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 142 ms
78,488 KB
testcase_15 AC 112 ms
77,116 KB
testcase_16 AC 127 ms
77,784 KB
testcase_17 AC 97 ms
76,384 KB
testcase_18 AC 187 ms
78,504 KB
testcase_19 AC 121 ms
78,656 KB
testcase_20 AC 122 ms
78,828 KB
testcase_21 AC 191 ms
78,960 KB
testcase_22 AC 111 ms
77,820 KB
testcase_23 AC 163 ms
77,976 KB
testcase_24 AC 171 ms
78,668 KB
testcase_25 AC 129 ms
78,112 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