結果
| 問題 |
No.1689 Set Cards
|
| コンテスト | |
| ユーザー |
ysystem7
|
| 提出日時 | 2021-10-11 12:22:41 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 2,000 ms |
| コード長 | 1,671 bytes |
| コンパイル時間 | 2,635 ms |
| コンパイル使用メモリ | 211,876 KB |
| 最終ジャッジ日時 | 2025-01-25 00:05:19 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
//#define mod 1000000007
#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline void out(T a){ cout << a << '\n'; }
void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;}
//void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;}
const ll INF=1e18;
const int mx=200005;
ll dp[505][(1<<12)+3];
int main(){
//オーバーフローは大丈夫ですか??
cin.tie(0);ios::sync_with_stdio(false);
int n;
cin>>n;
V<int> k(n);
V<int> c(n,0);
rep(i,n){
cin>>k[i];
int a;
rep(j,k[i]){
cin>>a;
a--;
c[i]|=(1<<a);
}
}
dp[0][(1<<12)-1]=1;
rep(i,n){
rep(j,(1<<12)){
int bit=(j&c[i]);
dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
dp[i+1][bit]=(dp[i+1][bit]+dp[i][j])%mod;
}
}
out(dp[n][0]);
}
ysystem7