結果

問題 No.1689 Set Cards
ユーザー ぷらぷら
提出日時 2021-09-24 21:51:29
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 733 bytes
コンパイル時間 2,014 ms
コンパイル使用メモリ 204,652 KB
実行使用メモリ 19,296 KB
最終ジャッジ日時 2023-09-18 21:12:47
合計ジャッジ時間 3,372 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 22 ms
19,132 KB
testcase_12 AC 22 ms
19,136 KB
testcase_13 AC 22 ms
19,088 KB
testcase_14 AC 22 ms
19,112 KB
testcase_15 AC 7 ms
7,196 KB
testcase_16 AC 16 ms
14,128 KB
testcase_17 AC 5 ms
5,960 KB
testcase_18 AC 22 ms
19,148 KB
testcase_19 AC 23 ms
19,144 KB
testcase_20 AC 23 ms
19,200 KB
testcase_21 AC 25 ms
19,296 KB
testcase_22 AC 24 ms
19,132 KB
testcase_23 AC 23 ms
19,168 KB
testcase_24 AC 23 ms
19,132 KB
testcase_25 AC 22 ms
19,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

constexpr int mod = 998244353;

int main() {
    int N;
    cin >> N;
    vector<int>C(N);
    for(int i = 0; i < N; i++) {
        int k;
        cin >> k;
        int sum = 0;
        for(int j = 0; j < k; j++) {
            int a;
            cin >> a;
            sum += 1 << (a-1);
        }
        C[i] = sum;
    }
    vector<vector<long long>>dp(N+1,vector<long long>(1 << 12));
    dp[0][(1 << 12)-1] = 1;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < (1 << 12); j++) {
            dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= mod;
            dp[i+1][j&C[i]] += dp[i][j];
            dp[i+1][j&C[i]] %= mod;
        }
    }
    cout << dp[N][0] << endl;
}
0