結果

問題 No.1689 Set Cards
ユーザー monnumonnu
提出日時 2021-10-02 09:58:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 986 bytes
コンパイル時間 3,746 ms
コンパイル使用メモリ 230,068 KB
実行使用メモリ 19,676 KB
最終ジャッジ日時 2023-09-27 09:37:49
合計ジャッジ時間 6,006 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 3 ms
4,540 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 23 ms
19,620 KB
testcase_12 AC 24 ms
19,636 KB
testcase_13 AC 24 ms
19,500 KB
testcase_14 AC 23 ms
19,520 KB
testcase_15 AC 7 ms
7,784 KB
testcase_16 AC 18 ms
14,596 KB
testcase_17 AC 5 ms
6,244 KB
testcase_18 AC 23 ms
19,512 KB
testcase_19 AC 22 ms
19,532 KB
testcase_20 AC 23 ms
19,500 KB
testcase_21 AC 29 ms
19,676 KB
testcase_22 AC 25 ms
19,540 KB
testcase_23 AC 26 ms
19,504 KB
testcase_24 AC 23 ms
19,584 KB
testcase_25 AC 24 ms
19,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 20005
//#define MOD 1000000007
#define MOD 998244353
//#define INF 1000000000
#define INF 1000000000000000000

int main(){
  int N;
  cin>>N;
  vector<int> k(N);
  vector<vector<int>> C(N);
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>k[i];
    C[i].resize(k[i]);
    for(int j=0;j<k[i];j++){
      cin>>C[i][j];
      C[i][j]--;
      A[i]+=(1<<C[i][j]);
    }
  }

  int M=12;
  vector<vector<ll>> dp(N+1,vector<ll>(1<<M,0));
  vector<ll> sum(1<<M,0);
  for(int i=0;i<N;i++){
    dp[i+1][A[i]]++;
    dp[i+1][A[i]]%=MOD;
    for(int j=0;j<(1<<M);j++){
      int bit=(j&A[i]);
      dp[i+1][bit]+=sum[j];
      dp[i+1][bit]%=MOD;
    }
    for(int j=0;j<(1<<M);j++){
      sum[j]+=dp[i+1][j];
      sum[j]%=MOD;
    }
  }

  ll ans=0;
  for(int i=1;i<=N;i++){
    ans+=dp[i][0];
    ans%=MOD;
  }
  cout<<ans<<'\n';
}
0