結果

問題 No.1689 Set Cards
ユーザー brthyyjpbrthyyjp
提出日時 2021-09-24 22:50:27
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,207 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 323,092 KB
最終ジャッジ日時 2023-09-18 21:55:56
合計ジャッジ時間 5,315 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
80,448 KB
testcase_01 AC 82 ms
75,992 KB
testcase_02 AC 210 ms
80,648 KB
testcase_03 AC 119 ms
76,424 KB
testcase_04 AC 120 ms
76,244 KB
testcase_05 AC 120 ms
76,484 KB
testcase_06 AC 120 ms
76,376 KB
testcase_07 AC 90 ms
75,640 KB
testcase_08 AC 79 ms
75,156 KB
testcase_09 AC 79 ms
75,180 KB
testcase_10 AC 98 ms
75,956 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import io, os
input = sys.stdin.buffer.readline
#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

def main():

    n = int(input())
    C = []
    for i in range(n):
        temp = list(map(int, input().split()))
        temp = temp[1:]
        if temp:
            temp = [i-1 for i in temp]
        v = 0
        for i in temp:
            v |= (1<<i)
        C.append(v)
    #print(C)
    mod = 998244353
    dp = [[0]*(1<<12) for i in range(n+1)]
    dp[0][0] = 1
    for i in range(n):
        nx = [[0]*(1<<12) for i in range(n+1)]
        for j in range(n+1):
            for s in range(1<<12):
                nx[j][s] = dp[j][s]
        v = C[i]
        for j in range(n):
            for s in range(1<<12):
                if j == 0:
                    if s == 0:
                        nx[j+1][s|v] += dp[j][s]
                        nx[j+1][s|v] %= mod
                    else:
                        break
                else:
                    nx[j+1][s&v] += dp[j][s]
                    nx[j+1][s&v] %= mod
        dp = nx
    ans = 0
    for j in range(1, n+1):
        ans += dp[j][0]
        ans %= mod
    print(ans)

if __name__ == '__main__':
    main()
0