結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 210 ms
4,348 KB
testcase_02 AC 211 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 5 ms
4,348 KB
testcase_09 AC 4 ms
4,348 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
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 = 4;
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