結果
問題 | No.2293 無向辺 2-SAT |
ユーザー | hikikomori |
提出日時 | 2023-04-04 03:16:43 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 701 ms / 4,000 ms |
コード長 | 3,536 bytes |
コンパイル時間 | 5,365 ms |
コンパイル使用メモリ | 319,140 KB |
実行使用メモリ | 28,920 KB |
最終ジャッジ日時 | 2024-05-02 03:56:52 |
合計ジャッジ時間 | 40,834 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 6 ms
11,048 KB |
testcase_01 | AC | 7 ms
11,008 KB |
testcase_02 | AC | 7 ms
11,128 KB |
testcase_03 | AC | 701 ms
28,920 KB |
testcase_04 | AC | 523 ms
20,608 KB |
testcase_05 | AC | 513 ms
20,460 KB |
testcase_06 | AC | 494 ms
20,316 KB |
testcase_07 | AC | 294 ms
17,280 KB |
testcase_08 | AC | 484 ms
20,192 KB |
testcase_09 | AC | 418 ms
19,328 KB |
testcase_10 | AC | 453 ms
19,328 KB |
testcase_11 | AC | 564 ms
20,544 KB |
testcase_12 | AC | 535 ms
20,224 KB |
testcase_13 | AC | 513 ms
20,352 KB |
testcase_14 | AC | 490 ms
20,300 KB |
testcase_15 | AC | 476 ms
20,304 KB |
testcase_16 | AC | 580 ms
20,580 KB |
testcase_17 | AC | 584 ms
21,292 KB |
testcase_18 | AC | 531 ms
20,480 KB |
testcase_19 | AC | 281 ms
15,872 KB |
testcase_20 | AC | 563 ms
20,480 KB |
testcase_21 | AC | 511 ms
20,388 KB |
testcase_22 | AC | 580 ms
20,908 KB |
testcase_23 | AC | 613 ms
21,000 KB |
testcase_24 | AC | 607 ms
20,896 KB |
testcase_25 | AC | 638 ms
20,864 KB |
testcase_26 | AC | 653 ms
21,012 KB |
testcase_27 | AC | 625 ms
20,888 KB |
testcase_28 | AC | 610 ms
21,036 KB |
testcase_29 | AC | 607 ms
20,896 KB |
testcase_30 | AC | 635 ms
21,020 KB |
testcase_31 | AC | 593 ms
21,020 KB |
testcase_32 | AC | 492 ms
20,060 KB |
testcase_33 | AC | 482 ms
20,096 KB |
testcase_34 | AC | 512 ms
20,124 KB |
testcase_35 | AC | 515 ms
20,064 KB |
testcase_36 | AC | 495 ms
20,224 KB |
testcase_37 | AC | 506 ms
20,096 KB |
testcase_38 | AC | 524 ms
20,096 KB |
testcase_39 | AC | 507 ms
20,080 KB |
testcase_40 | AC | 482 ms
20,096 KB |
testcase_41 | AC | 451 ms
19,840 KB |
testcase_42 | AC | 444 ms
20,052 KB |
testcase_43 | AC | 510 ms
20,072 KB |
testcase_44 | AC | 498 ms
20,236 KB |
testcase_45 | AC | 535 ms
20,296 KB |
testcase_46 | AC | 519 ms
20,336 KB |
testcase_47 | AC | 523 ms
20,480 KB |
testcase_48 | AC | 553 ms
20,400 KB |
testcase_49 | AC | 535 ms
20,580 KB |
testcase_50 | AC | 545 ms
20,552 KB |
testcase_51 | AC | 556 ms
20,480 KB |
testcase_52 | AC | 575 ms
20,736 KB |
testcase_53 | AC | 621 ms
20,872 KB |
testcase_54 | AC | 632 ms
21,360 KB |
testcase_55 | AC | 633 ms
22,004 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; using ll = long long; using ld = long double; using P = pair<int, int>; using Graph = vector<vector<ll>>; using vi = vector<int>; using vl = vector<long>; using vll = vector<long long>; using vvi = vector<vi>; using vvl = vector<vl>; using vvll = vector<vll>; using vs = vector<string>; using vc = vector<char>; using vvc = vector<vc>; using pll = pair<long long, long long>; using vpll = vector<pll>; using mint = modint998244353; const long double EPS = 1e-18; const long long INF = 1e18; const long double PI = acos(-1.0L); #define reps(i, a, n) for (ll i = (a); i < (ll)(n); i++) #define rep(i, n) for (ll i = (0); i < (ll)(n); i++) #define rrep(i, n) for (ll i = (1); i < (ll)(n + 1); i++) #define repd(i, n) for (ll i = n - 1; i >= 0; i--) #define rrepd(i, n) for (ll i = n; i >= 1; i--) #define ALL(n) begin(n), end(n) #define IN(a, x, b) (a <= x && x < b) #define INIT \ std::ios::sync_with_stdio(false); \ std::cin.tie(0); template <class T> inline T CHMAX(T& a, const T b) { return a = (a < b) ? b : a; } template <class T> inline T CHMIN(T& a, const T b) { return a = (a > b) ? b : a; } int main() { ll N, Q; cin >> N >> Q; mint ans = 0; mint def = mint(2).pow(N); ans = def; vll num(4e5 + 100, 0); vvll queee(2e5 + 100); rrep(i, Q) { ll q; cin >> q; queee[i].push_back(q); if (q != 3) { ll x, y; cin >> x >> y; queee[i].push_back(x); queee[i].push_back(y); } } ll right = 1; ll left = 1; while (left <= Q) { while (queee[right][0] != 3 && right < Q) { right++; } vll za; reps(i, left, right + 1) { if (queee[i][0] != 3) { za.push_back(queee[i][1]); za.push_back(queee[i][1] + N); za.push_back(queee[i][2]); za.push_back(queee[i][2] + N); } } sort(ALL(za)); za.erase(unique(ALL(za)), za.end()); dsu uf(za.size() + 10); reps(i, left, right + 1) { if (queee[i][0] == 1) { ll u = lower_bound(ALL(za), queee[i][1]) - za.begin(); ll v = lower_bound(ALL(za), queee[i][2]) - za.begin(); ll nu = lower_bound(ALL(za), queee[i][1] + N) - za.begin(); ll nv = lower_bound(ALL(za), queee[i][2] + N) - za.begin(); if (!uf.same(u, v)) { ans /= 2; } uf.merge(u, v); uf.merge(nu, nv); if (uf.same(u, nu) && uf.same(v, nv)) { ans = 0; } } else if (queee[i][0] == 2) { ll u = lower_bound(ALL(za), queee[i][1]) - za.begin(); ll v = lower_bound(ALL(za), queee[i][2]) - za.begin(); ll nu = lower_bound(ALL(za), queee[i][1] + N) - za.begin(); ll nv = lower_bound(ALL(za), queee[i][2] + N) - za.begin(); if (!uf.same(u, nv)) { ans /= 2; } uf.merge(u, nv); uf.merge(nu, v); if (uf.same(u, nu) && uf.same(v, nv)) { ans = 0; } } else { ans = def; } cout << ans.val() << endl; } right++; left = right; } }