結果

問題 No.2134 $\sigma$-algebra over Finite Set
ユーザー だれだれ
提出日時 2022-11-06 20:08:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,001 bytes
コンパイル時間 1,107 ms
コンパイル使用メモリ 95,256 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 16:20:06
合計ジャッジ時間 3,606 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 9 ms
4,348 KB
testcase_09 AC 7 ms
4,348 KB
testcase_10 RE -
testcase_11 WA -
testcase_12 RE -
testcase_13 WA -
testcase_14 AC 11 ms
4,348 KB
testcase_15 AC 15 ms
4,348 KB
testcase_16 AC 12 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;

const int MAX_N = 510;
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];
            }
        }
    }
    atcoder::dsu d(n);
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            if (B[i] == B[j]) {
                d.merge(i, j);
            }
        }
    }
    cout << atcoder::pow_mod(2, d.groups().size(), 998244353) << endl;
}
0