結果

問題 No.2134 $\sigma$-algebra over Finite Set
ユーザー ruthenruthen
提出日時 2022-11-26 00:18:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 964 bytes
コンパイル時間 2,230 ms
コンパイル使用メモリ 205,260 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-10 05:04:13
合計ジャッジ時間 3,402 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#ifdef _RUTHEN
#include <debug.hpp>
#else
#define show(...) true
#endif

using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
template <class T> using V = vector<T>;

#include <atcoder/dsu>
#include <atcoder/modint>
using mint = atcoder::modint998244353;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    atcoder::dsu uf(N);
    rep(i, M) {
        int L;
        cin >> L;
        V<int> A(L);
        rep(j, L) {
            cin >> A[j];
            A[j]--;
        }
        V<int> S(N);
        rep(j, L) S[A[j]] = 1;
        V<int> T;
        rep(j, N) if (S[j] == 0) T.push_back(j);
        rep(j, L - 1) uf.merge(A[j], A[j + 1]);
        int K = T.size();
        rep(j, K - 1) uf.merge(T[j], T[j + 1]);
    }
    mint ans = 0;
    rep(i, N) if (uf.leader(i) == i) ans += mint(2).pow(uf.size(i));
    cout << ans.val() << '\n';
    return 0;
}
0