結果

問題 No.1689 Set Cards
ユーザー puznekopuzneko
提出日時 2021-11-23 23:03:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 548 bytes
コンパイル時間 408 ms
コンパイル使用メモリ 87,140 KB
実行使用メモリ 90,296 KB
最終ジャッジ日時 2023-09-08 03:40:30
合計ジャッジ時間 4,766 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
76,040 KB
testcase_01 AC 75 ms
76,144 KB
testcase_02 AC 78 ms
76,272 KB
testcase_03 AC 75 ms
76,096 KB
testcase_04 AC 76 ms
76,100 KB
testcase_05 AC 76 ms
76,356 KB
testcase_06 AC 77 ms
76,060 KB
testcase_07 AC 74 ms
76,204 KB
testcase_08 AC 71 ms
76,224 KB
testcase_09 AC 74 ms
76,088 KB
testcase_10 AC 75 ms
76,200 KB
testcase_11 AC 128 ms
88,280 KB
testcase_12 AC 129 ms
88,176 KB
testcase_13 AC 127 ms
88,756 KB
testcase_14 AC 129 ms
88,296 KB
testcase_15 AC 84 ms
76,232 KB
testcase_16 AC 113 ms
88,448 KB
testcase_17 AC 80 ms
76,364 KB
testcase_18 AC 126 ms
87,656 KB
testcase_19 AC 127 ms
87,820 KB
testcase_20 AC 127 ms
87,668 KB
testcase_21 AC 128 ms
90,296 KB
testcase_22 AC 128 ms
89,912 KB
testcase_23 AC 126 ms
90,076 KB
testcase_24 AC 133 ms
87,884 KB
testcase_25 AC 126 ms
87,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin
n, *indata = map(int, stdin.read().split())
p = 998244353
setlist = [0 for i in range(n)]
offset = 0
for i in range(n):
    k = indata[offset]
    offset += 1
    for j in range(k):
        setlist[i] += 1 << (indata[offset+j]-1)
    offset += k

dp = [[0 for i in range(1<<12)] for j in range(n+1)]
dp[0][(1<<12)-1] = 1

for i in range(n):
    for j in range(1<<12):
        dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % p
        dp[i+1][(j & setlist[i])] = (dp[i+1][(j & setlist[i])] + dp[i][j]) % p

print("{}".format(dp[n][0]))
0