結果

問題 No.2134 $\sigma$-algebra over Finite Set
ユーザー だれだれ
提出日時 2022-11-12 17:07:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 223 ms / 2,000 ms
コード長 873 bytes
コンパイル時間 1,237 ms
コンパイル使用メモリ 98,524 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 12:48:12
合計ジャッジ時間 2,548 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 221 ms
5,376 KB
testcase_02 AC 223 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 10 ms
5,376 KB
testcase_07 AC 12 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 21 ms
5,376 KB
testcase_11 AC 22 ms
5,376 KB
testcase_12 AC 55 ms
5,376 KB
testcase_13 AC 115 ms
5,376 KB
testcase_14 AC 11 ms
5,376 KB
testcase_15 AC 15 ms
5,376 KB
testcase_16 AC 13 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <bitset>
#include <unordered_set>
#include <atcoder/math>

using namespace std;

const int MAX_N = 1010;
using bit = bitset<MAX_N>;

int main() {
    int n, m;
    cin >> n >> m;
    bit tmp;
    for (int i = 0; i < n; i++) tmp[i] = 1;
    vector<bit> B(n, tmp), A(m), A_c(m);
    for (int i = 0; i < m; i++) {
        int l;
        cin >> l;
        for (int j = 0; j < l; j++) {
            int a;
            cin >> a;
            a--;
            A[i][a] = 1;
        }
        A_c[i] = ~A[i];
        for (int j = 0; j < n; j++) {
            if (A[i][j]) {
                B[j] &= A[i];
            }
            else {
                B[j] &= A_c[i];
            }
        }
    }
    unordered_set<bit> s;
    for (int i = 0; i < n; i++) s.insert(B[i]);
    cout << atcoder::pow_mod(2, s.size(), 998244353) << endl;
}
0