結果

問題 No.1689 Set Cards
ユーザー Manuel1024Manuel1024
提出日時 2022-12-11 21:52:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 795 bytes
コンパイル時間 679 ms
コンパイル使用メモリ 73,716 KB
実行使用メモリ 19,712 KB
最終ジャッジ日時 2024-04-23 16:42:34
合計ジャッジ時間 1,969 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 21 ms
19,584 KB
testcase_12 AC 21 ms
19,584 KB
testcase_13 AC 23 ms
19,712 KB
testcase_14 AC 21 ms
19,712 KB
testcase_15 AC 7 ms
7,808 KB
testcase_16 AC 16 ms
14,592 KB
testcase_17 AC 6 ms
6,400 KB
testcase_18 AC 21 ms
19,456 KB
testcase_19 AC 22 ms
19,712 KB
testcase_20 AC 21 ms
19,456 KB
testcase_21 AC 27 ms
19,584 KB
testcase_22 AC 24 ms
19,712 KB
testcase_23 AC 24 ms
19,584 KB
testcase_24 AC 22 ms
19,584 KB
testcase_25 AC 22 ms
19,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
constexpr ll MOD = 998244353;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        int k; cin >> k;
        for(int j = 0; j < k; j++){
            int c; cin >> c;
            c--;
            a[i] |= 1 << c;
        }
    }

    vector<vector<ll>> dp(n+10, vector<ll>(1 << 12, 0));
    for(int i = 0; i < n; i++){
        for(int bit = 0; bit < (1 << 12); bit++){
            dp[i+1][bit] = dp[i][bit];
        }
        for(int bit = 0; bit < (1 << 12); bit++){
            dp[i+1][bit & a[i]] += dp[i][bit];
            dp[i+1][bit & a[i]] %= MOD;
        }
        dp[i+1][a[i]] += 1;
        dp[i+1][a[i]] %= MOD;
    }
    cout << dp[n][0] << endl;
    return 0;
}
0