結果

問題 No.1689 Set Cards
ユーザー yel_ow
提出日時 2025-06-14 00:16:58
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 465 ms / 2,000 ms
コード長 937 bytes
コンパイル時間 5,707 ms
コンパイル使用メモリ 334,996 KB
実行使用メモリ 278,528 KB
最終ジャッジ日時 2025-06-14 00:17:11
合計ジャッジ時間 12,623 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

//#include <monsterenergy>
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int MAX = 1e9;
const int MIN = -1*1e9;
const ll MAXLL = 1e18;
const ll MINLL = -1*1e18;

int main()
{
    int N; cin >> N;
    vector DP(N+1,vector(10000,vector<mint>(2)));
    DP[0][0][0] = 1;
    for(int i = 0; i < N; i++)
    {
        int A,B=0; cin >> A;
        for(int j = 0; j < A; j++)
        {
            int C; cin >> C;
            C--;
            B |= (1<<C);
        }
        for(int j = 0; j < (1<<12); j++)
        {
            DP[i+1][B][1] += DP[i][j][0];
            DP[i+1][(j&B)][1] += DP[i][j][1];
            DP[i+1][j][0] += DP[i][j][0];
            DP[i+1][j][1] += DP[i][j][1];
        }
    }
    cout << DP[N][0][1].val() << endl;
    return 0;
}
0