結果

問題 No.2293 無向辺 2-SAT
ユーザー t98slidert98slider
提出日時 2023-05-07 18:11:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 463 ms / 4,000 ms
コード長 849 bytes
コンパイル時間 3,593 ms
コンパイル使用メモリ 230,280 KB
実行使用メモリ 7,020 KB
最終ジャッジ日時 2024-05-03 15:45:06
合計ジャッジ時間 33,302 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 395 ms
7,020 KB
testcase_04 AC 411 ms
5,376 KB
testcase_05 AC 399 ms
5,376 KB
testcase_06 AC 382 ms
5,376 KB
testcase_07 AC 272 ms
5,376 KB
testcase_08 AC 393 ms
5,376 KB
testcase_09 AC 380 ms
5,376 KB
testcase_10 AC 379 ms
5,376 KB
testcase_11 AC 415 ms
5,376 KB
testcase_12 AC 397 ms
5,376 KB
testcase_13 AC 415 ms
5,376 KB
testcase_14 AC 363 ms
5,376 KB
testcase_15 AC 353 ms
5,376 KB
testcase_16 AC 415 ms
5,376 KB
testcase_17 AC 400 ms
5,376 KB
testcase_18 AC 390 ms
5,376 KB
testcase_19 AC 194 ms
5,376 KB
testcase_20 AC 406 ms
5,376 KB
testcase_21 AC 426 ms
5,376 KB
testcase_22 AC 461 ms
5,376 KB
testcase_23 AC 404 ms
5,376 KB
testcase_24 AC 406 ms
5,376 KB
testcase_25 AC 406 ms
5,376 KB
testcase_26 AC 404 ms
5,376 KB
testcase_27 AC 410 ms
5,376 KB
testcase_28 AC 402 ms
5,376 KB
testcase_29 AC 409 ms
5,376 KB
testcase_30 AC 404 ms
5,376 KB
testcase_31 AC 403 ms
5,376 KB
testcase_32 AC 383 ms
5,376 KB
testcase_33 AC 391 ms
5,376 KB
testcase_34 AC 423 ms
5,376 KB
testcase_35 AC 381 ms
5,376 KB
testcase_36 AC 415 ms
5,376 KB
testcase_37 AC 382 ms
5,376 KB
testcase_38 AC 389 ms
5,376 KB
testcase_39 AC 383 ms
5,376 KB
testcase_40 AC 386 ms
5,376 KB
testcase_41 AC 373 ms
5,376 KB
testcase_42 AC 390 ms
5,376 KB
testcase_43 AC 398 ms
5,376 KB
testcase_44 AC 389 ms
5,376 KB
testcase_45 AC 399 ms
5,376 KB
testcase_46 AC 402 ms
5,376 KB
testcase_47 AC 421 ms
5,376 KB
testcase_48 AC 420 ms
5,376 KB
testcase_49 AC 402 ms
5,376 KB
testcase_50 AC 411 ms
5,376 KB
testcase_51 AC 397 ms
5,376 KB
testcase_52 AC 417 ms
5,376 KB
testcase_53 AC 398 ms
5,376 KB
testcase_54 AC 407 ms
5,376 KB
testcase_55 AC 463 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define private public
#include <atcoder/all>
using namespace std;

int main(){
    int N, Q, type, u, v, num;
    cin >> N >> Q;
    num = N;
    bool zero = false;
    atcoder::dsu uf(2 * N);
    vector<int> memo;
    while(Q--){
        cin >> type;
        if(--type < 2){
            cin >> u >> v;
            memo.push_back(--u);
            memo.push_back(--v);
            if(!uf.same(u, v + type * N)) num--;
            uf.merge(u, v + type * N);
            uf.merge(u + N, v + (1 ^ type) * N);
            if(uf.same(u, u + N)) zero = true;
        }else{
            num = N;
            zero = false;
            for(int v : memo) uf.parent_or_size[v] = uf.parent_or_size[v + N] = -1;
            memo.clear();
        }
        cout << (zero ? 0 : atcoder::modint998244353(2).pow(num).val()) << '\n';
    }
}
0