結果

問題 No.1689 Set Cards
ユーザー qibqib
提出日時 2022-12-12 00:42:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 454 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 81,976 KB
実行使用メモリ 76,980 KB
最終ジャッジ日時 2024-04-23 18:55:53
合計ジャッジ時間 2,965 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
58,892 KB
testcase_01 AC 40 ms
59,056 KB
testcase_02 AC 45 ms
62,652 KB
testcase_03 AC 44 ms
61,924 KB
testcase_04 AC 43 ms
62,068 KB
testcase_05 AC 46 ms
61,708 KB
testcase_06 AC 47 ms
61,944 KB
testcase_07 AC 43 ms
60,392 KB
testcase_08 AC 39 ms
58,932 KB
testcase_09 AC 40 ms
58,364 KB
testcase_10 AC 43 ms
59,784 KB
testcase_11 AC 90 ms
76,504 KB
testcase_12 AC 90 ms
76,700 KB
testcase_13 AC 81 ms
76,800 KB
testcase_14 AC 84 ms
76,688 KB
testcase_15 AC 53 ms
66,440 KB
testcase_16 AC 71 ms
76,564 KB
testcase_17 AC 49 ms
64,640 KB
testcase_18 AC 88 ms
76,500 KB
testcase_19 AC 79 ms
76,592 KB
testcase_20 AC 76 ms
76,716 KB
testcase_21 AC 72 ms
76,472 KB
testcase_22 AC 72 ms
76,980 KB
testcase_23 AC 71 ms
76,512 KB
testcase_24 AC 99 ms
76,528 KB
testcase_25 AC 85 ms
76,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353

# No. 1689
n = int(input())

dp = [0 for _ in range(1 << 12)]
dp[-1] = 1
for _ in range(n):
  row = list(map(int, input().split()))
  mask = 0
  for i in range(row[0]):
    mask |= (1 << (row[i + 1] - 1))

  ndp = [0 for _ in range(1 << 12)]
  for cur in range(1 << 12):
    if dp[cur] == 0:
      continue

    ndp[cur] = (ndp[cur] + dp[cur]) % MOD
    nxt = cur & mask
    ndp[nxt] = (ndp[nxt] + dp[cur]) % MOD
  dp = ndp

print(dp[0])
0