結果
問題 |
No.2134 $\sigma$-algebra over Finite Set
|
ユーザー |
|
提出日時 | 2022-11-26 00:18:50 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 964 bytes |
コンパイル時間 | 2,004 ms |
コンパイル使用メモリ | 204,304 KB |
最終ジャッジ日時 | 2025-02-09 01:08:54 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 9 WA * 8 |
ソースコード
#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; }