結果

問題 No.2293 無向辺 2-SAT
ユーザー t98slidert98slider
提出日時 2023-05-07 18:11:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 470 ms / 4,000 ms
コード長 849 bytes
コンパイル時間 4,123 ms
コンパイル使用メモリ 228,348 KB
実行使用メモリ 6,660 KB
最終ジャッジ日時 2023-08-16 06:39:32
合計ジャッジ時間 40,936 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 3 ms
4,732 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 470 ms
6,660 KB
testcase_04 AC 450 ms
4,664 KB
testcase_05 AC 453 ms
4,380 KB
testcase_06 AC 428 ms
4,380 KB
testcase_07 AC 303 ms
4,924 KB
testcase_08 AC 443 ms
4,604 KB
testcase_09 AC 411 ms
4,608 KB
testcase_10 AC 404 ms
4,744 KB
testcase_11 AC 447 ms
4,668 KB
testcase_12 AC 447 ms
4,672 KB
testcase_13 AC 395 ms
4,380 KB
testcase_14 AC 381 ms
4,380 KB
testcase_15 AC 372 ms
4,380 KB
testcase_16 AC 458 ms
4,736 KB
testcase_17 AC 456 ms
5,080 KB
testcase_18 AC 449 ms
4,684 KB
testcase_19 AC 219 ms
4,384 KB
testcase_20 AC 457 ms
4,672 KB
testcase_21 AC 444 ms
4,620 KB
testcase_22 AC 449 ms
4,896 KB
testcase_23 AC 454 ms
4,896 KB
testcase_24 AC 454 ms
5,032 KB
testcase_25 AC 461 ms
4,932 KB
testcase_26 AC 453 ms
4,888 KB
testcase_27 AC 454 ms
4,864 KB
testcase_28 AC 453 ms
4,876 KB
testcase_29 AC 457 ms
4,820 KB
testcase_30 AC 469 ms
4,956 KB
testcase_31 AC 463 ms
4,956 KB
testcase_32 AC 436 ms
4,612 KB
testcase_33 AC 433 ms
4,656 KB
testcase_34 AC 431 ms
4,684 KB
testcase_35 AC 442 ms
4,728 KB
testcase_36 AC 427 ms
4,736 KB
testcase_37 AC 433 ms
4,668 KB
testcase_38 AC 444 ms
4,616 KB
testcase_39 AC 432 ms
4,764 KB
testcase_40 AC 438 ms
4,660 KB
testcase_41 AC 421 ms
4,652 KB
testcase_42 AC 414 ms
4,652 KB
testcase_43 AC 429 ms
4,652 KB
testcase_44 AC 435 ms
4,672 KB
testcase_45 AC 447 ms
4,692 KB
testcase_46 AC 449 ms
4,672 KB
testcase_47 AC 450 ms
4,676 KB
testcase_48 AC 448 ms
4,620 KB
testcase_49 AC 455 ms
4,652 KB
testcase_50 AC 458 ms
4,736 KB
testcase_51 AC 454 ms
4,800 KB
testcase_52 AC 460 ms
4,764 KB
testcase_53 AC 465 ms
4,908 KB
testcase_54 AC 466 ms
4,948 KB
testcase_55 AC 454 ms
5,032 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