結果

問題 No.2292 Interval Union Find
ユーザー hikikomorihikikomori
提出日時 2023-03-30 01:09:46
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,468 bytes
コンパイル時間 5,511 ms
コンパイル使用メモリ 319,884 KB
実行使用メモリ 48,288 KB
最終ジャッジ日時 2024-09-22 02:28:40
合計ジャッジ時間 32,117 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
7,936 KB
testcase_01 AC 6 ms
7,936 KB
testcase_02 AC 6 ms
7,936 KB
testcase_03 WA -
testcase_04 AC 533 ms
26,180 KB
testcase_05 AC 507 ms
26,184 KB
testcase_06 AC 520 ms
26,188 KB
testcase_07 AC 490 ms
25,556 KB
testcase_08 AC 648 ms
46,664 KB
testcase_09 AC 657 ms
46,540 KB
testcase_10 AC 650 ms
46,660 KB
testcase_11 AC 662 ms
46,536 KB
testcase_12 AC 663 ms
46,532 KB
testcase_13 AC 646 ms
46,276 KB
testcase_14 AC 653 ms
46,408 KB
testcase_15 AC 660 ms
46,412 KB
testcase_16 AC 645 ms
46,284 KB
testcase_17 AC 678 ms
46,532 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 534 ms
48,164 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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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);
    lazy_segtree<S, op, e, F, mapping, composition, id> seg2(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);
            seg2.apply(l, r + 1, 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);
            seg2.apply(l, r + 1, 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 << seg2.prod(l, r + 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;
        }
    }
}
0