結果
| 問題 | No.1689 Set Cards |
| コンテスト | |
| ユーザー |
SidewaysOwl
|
| 提出日時 | 2021-09-25 14:45:10 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 161 ms / 2,000 ms |
| コード長 | 1,011 bytes |
| 記録 | |
| コンパイル時間 | 145 ms |
| コンパイル使用メモリ | 82,216 KB |
| 実行使用メモリ | 77,376 KB |
| 最終ジャッジ日時 | 2024-07-05 12:05:33 |
| 合計ジャッジ時間 | 3,188 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
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)
SidewaysOwl