結果
問題 | No.2292 Interval Union Find |
ユーザー | hikikomori |
提出日時 | 2023-03-30 02:03:29 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 663 ms / 5,000 ms |
コード長 | 3,311 bytes |
コンパイル時間 | 5,880 ms |
コンパイル使用メモリ | 319,940 KB |
実行使用メモリ | 36,004 KB |
最終ジャッジ日時 | 2024-09-22 02:29:14 |
合計ジャッジ時間 | 31,162 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 6 ms
8,064 KB |
testcase_01 | AC | 6 ms
7,936 KB |
testcase_02 | AC | 7 ms
7,936 KB |
testcase_03 | AC | 7 ms
7,936 KB |
testcase_04 | AC | 502 ms
23,368 KB |
testcase_05 | AC | 491 ms
23,112 KB |
testcase_06 | AC | 526 ms
23,076 KB |
testcase_07 | AC | 479 ms
22,652 KB |
testcase_08 | AC | 632 ms
34,248 KB |
testcase_09 | AC | 606 ms
34,248 KB |
testcase_10 | AC | 663 ms
34,248 KB |
testcase_11 | AC | 614 ms
34,248 KB |
testcase_12 | AC | 602 ms
34,332 KB |
testcase_13 | AC | 592 ms
33,868 KB |
testcase_14 | AC | 604 ms
34,248 KB |
testcase_15 | AC | 615 ms
34,252 KB |
testcase_16 | AC | 613 ms
33,992 KB |
testcase_17 | AC | 612 ms
34,372 KB |
testcase_18 | AC | 310 ms
35,876 KB |
testcase_19 | AC | 434 ms
36,004 KB |
testcase_20 | AC | 441 ms
36,000 KB |
testcase_21 | AC | 490 ms
35,180 KB |
testcase_22 | AC | 491 ms
35,172 KB |
testcase_23 | AC | 490 ms
35,044 KB |
testcase_24 | AC | 496 ms
35,176 KB |
testcase_25 | AC | 497 ms
35,048 KB |
testcase_26 | AC | 495 ms
35,048 KB |
testcase_27 | AC | 504 ms
35,048 KB |
testcase_28 | AC | 496 ms
35,048 KB |
testcase_29 | AC | 504 ms
35,024 KB |
testcase_30 | AC | 497 ms
35,048 KB |
testcase_31 | AC | 491 ms
35,052 KB |
testcase_32 | AC | 490 ms
35,048 KB |
testcase_33 | AC | 498 ms
35,048 KB |
testcase_34 | AC | 490 ms
35,048 KB |
testcase_35 | AC | 497 ms
35,176 KB |
testcase_36 | AC | 502 ms
35,048 KB |
testcase_37 | AC | 488 ms
35,048 KB |
testcase_38 | AC | 496 ms
35,048 KB |
testcase_39 | AC | 494 ms
35,144 KB |
testcase_40 | AC | 494 ms
35,044 KB |
testcase_41 | AC | 273 ms
19,272 KB |
testcase_42 | AC | 274 ms
19,336 KB |
testcase_43 | AC | 294 ms
19,272 KB |
testcase_44 | AC | 375 ms
19,272 KB |
testcase_45 | AC | 380 ms
19,408 KB |
testcase_46 | AC | 381 ms
19,400 KB |
testcase_47 | AC | 420 ms
19,528 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 = 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); } if (l != r) { cout << seg.prod(l, r) << endl; } else { cout << 1 << 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; } } }