結果

問題 No.2134 $\sigma$-algebra over Finite Set
ユーザー kuronikuroni
提出日時 2022-11-26 06:15:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 888 bytes
コンパイル時間 1,962 ms
コンパイル使用メモリ 173,600 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 12:52:17
合計ジャッジ時間 3,191 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 85 ms
5,376 KB
testcase_02 AC 85 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 5 ms
5,376 KB
testcase_07 AC 6 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 13 ms
5,376 KB
testcase_11 AC 13 ms
5,376 KB
testcase_12 AC 26 ms
5,376 KB
testcase_13 AC 45 ms
5,376 KB
testcase_14 AC 6 ms
5,376 KB
testcase_15 AC 8 ms
5,376 KB
testcase_16 AC 7 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using mint = modint998244353;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m; cin >> n >> m;
    vector<int> ans(n), per(n);
    iota(per.begin(), per.end(), 0);
    while (m--) {
        int k; cin >> k;
        vector<bool> ok(n);
        for (int i = 0; i < k; i++) {
            int u; cin >> u; u--;
            ok[u] = true;
        }
        stable_partition(per.begin(), per.end(), [&](int u) { return ok[u]; });
        for (int cur = 0, i = 0; i < n; i++) {
            int nxt = cur + (i + 1 < n && 
                make_pair(ans[per[i]], ok[per[i]]) !=
                make_pair(ans[per[i + 1]], ok[per[i + 1]]));
            ans[per[i]] = cur;
            cur = nxt;
        }
    }
    cout << mint(2).pow(ans[per[n - 1]] + 1).val();
}
0