結果
問題 | No.2292 Interval Union Find |
ユーザー | hikikomori |
提出日時 | 2023-03-30 00:30:21 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,211 bytes |
コンパイル時間 | 6,554 ms |
コンパイル使用メモリ | 321,376 KB |
実行使用メモリ | 36,008 KB |
最終ジャッジ日時 | 2024-09-22 02:28:05 |
合計ジャッジ時間 | 31,781 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
7,936 KB |
testcase_01 | AC | 5 ms
7,936 KB |
testcase_02 | AC | 5 ms
8,064 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 489 ms
23,112 KB |
testcase_06 | WA | - |
testcase_07 | AC | 480 ms
22,528 KB |
testcase_08 | AC | 605 ms
34,372 KB |
testcase_09 | AC | 611 ms
34,380 KB |
testcase_10 | AC | 620 ms
34,372 KB |
testcase_11 | AC | 609 ms
34,248 KB |
testcase_12 | AC | 606 ms
34,372 KB |
testcase_13 | AC | 591 ms
33,988 KB |
testcase_14 | AC | 601 ms
34,120 KB |
testcase_15 | AC | 614 ms
34,120 KB |
testcase_16 | AC | 604 ms
34,120 KB |
testcase_17 | AC | 617 ms
34,372 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 453 ms
35,856 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
ソースコード
#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 = modint1000000007; const long double EPS = 1e-18; 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; } using S = long long; using F = long long; const S INF = 8e18; const F ID = 8e18; S op(S a, S b) { return std::min(a, b); } S e() { return INF; } S mapping(F f, S x) { return (f == ID ? x : f); } F composition(F f, F g) { return (f == ID ? g : f); } F id() { return ID; } ll target = 0; bool g(S x) { return x > target; } int main() { ll N; cin >> N; ll Q; cin >> Q; vll za; za.push_back(0); za.push_back(1e9 + 100); vvll query(2e5 + 50); rrep(i, Q) { ll type; cin >> type; query[i].push_back(type); if (type != 4) { ll u, v; cin >> u >> v; query[i].push_back(u); query[i].push_back(v); za.push_back(u); za.push_back(v); } else { ll u; cin >> u; query[i].push_back(u); za.push_back(u); } } sort(ALL(za)); za.erase(unique(ALL(za)), za.end()); ll n = za.size(); vector<S> v(n, 0); lazy_segtree<S, op, e, F, mapping, composition, id> seg(v); rrep(i, Q) { if (query[i][0] == 1) { ll l = lower_bound(ALL(za), query[i][1]) - za.begin(); ll r = lower_bound(ALL(za), query[i][2]) - za.begin(); seg.apply(l, r, 1); } else if (query[i][0] == 2) { ll l = lower_bound(ALL(za), query[i][1]) - za.begin(); ll r = lower_bound(ALL(za), query[i][2]) - za.begin(); seg.apply(l, r, 0); } else if (query[i][0] == 3) { ll l = lower_bound(ALL(za), query[i][1]) - za.begin(); ll r = lower_bound(ALL(za), query[i][2]) - za.begin(); if (r < l) { swap(l, r); } cout << seg.prod(l, r) << endl; } else { ll hei = lower_bound(ALL(za), query[i][1]) - za.begin(); ll r = seg.max_right<g>(hei); ll l = seg.min_left<g>(hei); cout << za[r] - za[l] + 1 << endl; } } }