QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#884363#3554. Sweepingmakrav#0 0ms0kbC++203.5kb2025-02-06 01:02:102025-02-06 01:02:10

Judging History

This is the latest submission verdict.

  • [2025-02-06 01:02:10]
  • Judged
  • Verdict: 0
  • Time: 0ms
  • Memory: 0kb
  • [2025-02-06 01:02:10]
  • Submitted

answer

#include <bits/stdc++.h>
#include <cassert>

using namespace std;

#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

struct segtree {
    int n, tim = 0;
    vector<pair<int, int>> t;
    segtree() = default;
    segtree(int n_) {
        n = n_;
        t.resize(4 * n, {-1, -1});
    }

    void upd(int l, int r, int x) {
        tim++;
        upddud(1, 0, n, l, r, x);
    }

    void upddud(int v, int tl, int tr, int l, int r, int x) {
        if (l <= tl && tr <= r) {
            t[v] = {x, tim};
            return;
        }
        if (tr <= l || tl >= r) return;
        int tm = (tl + tr) / 2;
        upddud(v * 2, tl, tm, l, r, x);
        upddud(v * 2 + 1, tm, tr, l, r, x);
    }

    int get(int p) {
        int v = 1, tl = 0, tr = n;
        pair<int, int> cur = t[v];
        while (tl + 1 < tr) {
            int tm = (tl + tr) /2;
            if (p < tm) {
                v *= 2; tr = tm;
            } else {
                v = v * 2 + 1;
                tl = tm;
            }
            if (t[v].second < cur.second) cur = t[v];
        }
        return cur.first;
    }
};

void solve() {
    int n, m, q; cin >> n >> m >> q;
    vector<pair<int, int>> a(m);
    for (int i = 0; i < m; i++) cin >> a[i].first >> a[i].second;
    vector<int> l(m), r(m);
    for (int i = 0; i < m; i++) {
        l[i] = a[i].first; r[i] = n - a[i].second;
    }
    segtree sgl(n), sgr(n);
    for (int i = 0; i < n; i++) {
        sgl.upd(i, i + 1, l[i]);
        sgr.upd(i, i + 1, r[i]);
    }
    while (q--) {
        int t; cin >> t;
        if (t == 1) {
            int ind; cin >> ind; ind--;
            cout << sgl.get(ind) << ' ' << n - sgr.get(ind) << '\n';
        } else if (t == 2) {
            int hg; cin >> hg;
            int curpt = n - hg;
            int L = -1, R = m;
            while (R - L > 1) {
                int M = (L + R) / 2;
                if (sgl.get(M) <= curpt) L = M;
                else R = M;
            }
            int rg = L;
            L = -1; R = m;
            while (R - L > 1) {
                int M = (L + R) / 2;
                if (sgr.get(M) >= curpt) R = M;
                else L = M;
            }
            if (R <= rg) {
                sgl.upd(R, rg, curpt);
            }
            // for (int i = 0; i < m; i++) {
            //     if (l[i] <= curpt && curpt <= r[i]) l[i] = curpt;
            // }
        } else if (t == 3) {
            int wg; cin >> wg;
            int curpt = wg;
            int L = -1, R = m;
            while (R - L > 1) {
                int M = (L + R) / 2;
                if (sgl.get(M) <= curpt) L = M;
                else R = M;
            }
            int rg = L;
            L = -1; R = m;
            while (R - L > 1) {
                int M = (L + R) / 2;
                if (sgr.get(M) >= curpt) R = M;
                else L = M;
            }
            if (R <= rg) {
                sgr.upd(R, rg, curpt);
            }
        } else {
            int x, y; cin >> x >> y;
            a.pb({x, y});
            l.pb(x); r.pb(n - y);
            m++;
        }
    }
}

signed main() {
    int tt = 1;
    #ifdef LOCAL 
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        cin >> tt;
    #else 
        cin.tie(0)->sync_with_stdio(false);
    #endif

    while (tt--) {
        solve();
    }
    return 0;
}

詳細信息

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 0
Runtime Error

input:

999999999 2000 5000
406191928 499382196
562579162 405324970
758918451 226610082
56425557 481714604
280111172 204083332
178122667 423322594
656895843 125933171
283229448 255332800
375268656 368221716
287124150 218833686
67804037 252992256
736660159 61831334
50624783 762562411
127286172 739867871
2174...

output:


result:


Subtask #2:

score: 0
Runtime Error

Test #7:

score: 0
Runtime Error

input:

1000000000 500000 1000000
565671866 434313351
151160620 848839277
759673958 240326022
747919325 251939968
652216454 341792707
697972826 302025968
437943290 562056699
963595717 25130832
833492450 163447023
453783218 546216655
852488265 147511733
364464144 334147914
493873353 504061372
104992045 86556...

output:


result:


Subtask #3:

score: 0
Runtime Error

Test #14:

score: 0
Runtime Error

input:

1000000000 499999 1000000
1603 999995752
1621 999984188
3408 999983654
3743 999979285
3830 999978594
5050 999974201
7426 999970241
13957 999962424
14611 999962335
16341 999954169
20684 999953545
21401 999952737
25492 999948443
25736 999946928
26128 999941492
29341 999937495
29753 999929827
33929 999...

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%