結果

問題 No.1689 Set Cards
ユーザー yakkiyakki
提出日時 2021-09-24 22:30:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 1,400 bytes
コンパイル時間 1,078 ms
コンパイル使用メモリ 123,456 KB
実行使用メモリ 19,668 KB
最終ジャッジ日時 2023-09-18 21:45:53
合計ジャッジ時間 3,027 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 3 ms
4,580 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 4 ms
4,380 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 3 ms
4,380 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 53 ms
19,440 KB
testcase_12 AC 53 ms
19,420 KB
testcase_13 AC 32 ms
19,476 KB
testcase_14 AC 38 ms
19,388 KB
testcase_15 AC 17 ms
7,824 KB
testcase_16 AC 32 ms
14,592 KB
testcase_17 AC 11 ms
6,148 KB
testcase_18 AC 55 ms
19,300 KB
testcase_19 AC 144 ms
19,396 KB
testcase_20 AC 143 ms
19,512 KB
testcase_21 AC 30 ms
19,368 KB
testcase_22 AC 30 ms
19,560 KB
testcase_23 AC 30 ms
19,364 KB
testcase_24 AC 129 ms
19,668 KB
testcase_25 AC 110 ms
19,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<ctime>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0)

const double EPS = 1e-18;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;
//using mint = modint998244353;

int dh[] = {-1,1,0,0};
int dw[] = {0,0,1,-1};

ll dp[550][1<<12];

int main(){
    int n; cin >> n;
    vector<vector<int>> c(n);
    rep(i,n){
        int k; cin >> k;
        c[i].resize(k);
        rep(j,k){
            cin >> c[i][j];
            c[i][j]--;
        }
    }
    dp[0][(1<<12)-1] = 1;
    rep(i,n)for(int j = (1<<12)-1; j >= 0; j--){
        int k = c[i].size();
        int tmp = 0;
        rep(l,k){
            if(j>>c[i][l]&1) tmp += 1<<c[i][l];
        }
        dp[i+1][tmp] += dp[i][j];
        dp[i+1][tmp] %= MOD;
        dp[i+1][j] += dp[i][j];
        dp[i+1][j] %= MOD;
    }
    cout << dp[n][0] << endl;

}
0