結果
| 問題 |
No.1689 Set Cards
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2021-09-25 02:48:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 18 ms / 2,000 ms |
| コード長 | 1,183 bytes |
| コンパイル時間 | 627 ms |
| コンパイル使用メモリ | 93,552 KB |
| 実行使用メモリ | 11,776 KB |
| 最終ジャッジ日時 | 2024-07-05 11:57:05 |
| 合計ジャッジ時間 | 1,467 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 1689.cc: No.1689 Set Cards - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_N = 500;
const int MAX_K = 12;
const int KBITS = 1 << MAX_K;
const int MOD = 998244353;
/* typedef */
/* global variables */
int bs[MAX_N], dp[MAX_N + 1][KBITS];
/* subroutines */
inline void addmod(int &a, int b) { a = (a + b) % MOD; }
/* main */
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
int ki;
scanf("%d", &ki);
for (int j = 0; j < ki; j++) {
int cj;
scanf("%d", &cj), cj--;
bs[i] |= (1 << cj);
}
}
dp[0][KBITS - 1] = 1;
for (int i = 0; i < n; i++)
for (int bits = 0; bits < KBITS; bits++)
if (dp[i][bits] > 0) {
addmod(dp[i + 1][bits], dp[i][bits]);
addmod(dp[i + 1][bits & bs[i]], dp[i][bits]);
}
printf("%d\n", dp[n][0]);
return 0;
}
tnakao0123