QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#884356#3554. Sweepingmakrav#0 538ms37768kbC++203.6kb2025-02-06 00:44:122025-02-06 00:44:13

Judging History

This is the latest submission verdict.

  • [2025-02-06 00:44:13]
  • Judged
  • Verdict: 0
  • Time: 538ms
  • Memory: 37768kb
  • [2025-02-06 00:44:12]
  • 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; 
    vector<int> t;
    segtree() = default;
    segtree(int n_) {
        n = n_;
        t.assign(4 * n, 1e9 + 1);
    }
    void upd(int v, int tl, int tr, int l, int r, int x) {
        if (l <= tl && tr <= r) {
            t[v] = min(t[v], x);
            return;
        }
        if (tr <= l || tl >= r) return;
        int tm = (tl + tr) / 2;
        upd(v * 2, tl, tm, l, r, x); upd(v * 2 + 1, tm, tr, l, r, x);
    }
    void free(int id) {
        int v = 1, tl = 0, tr = n;
        while (tl + 1 < tr) {
            int tm = (tl + tr) / 2;
            if (id < tm) {
                v *= 2; tr = tm;
            } else {
                v = v * 2 + 1;
                tl = tm;
            }
        }
        t[v] = 1e9 + 1;
        int prv = v;
        v >>= 1;
        while (v) {
            if (prv & 1) {
                t[v * 2] = min(t[v * 2], t[v]);
            } else {
                t[v * 2 + 1] = min(t[v * 2 + 1], t[v]);
            }
            t[v] = 1e9 + 1;
            prv = v; 
            v >>= 1;
        }
    }
    int get(int id) {
        int v = 1, tl = 0, tr = n;
        int ans = t[v];
        while (tl + 1 < tr) {
            int tm = (tl + tr) / 2;
            if (id < tm) {
                v *= 2; tr = tm;
            } else {
                v = v * 2 + 1;
                tl = tm;
            }
            ans = min(ans, t[v]);
        }
        return ans;
    }
};

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;
    }
    vector<pair<int, int>> queries(q);
    for (int i = 0; i < q; i++) {
        int t; cin >> t;
        if (t == 1) {
            int ind; cin >> ind; ind--;
            queries[i] = {0, ind};
        } else if (t == 2) {
            int hg; cin >> hg;
            queries[i] = {1, hg};
        } else if (t == 3) {
            int wg; cin >> wg; continue;
        } else {
            int x, y; cin >> x >> y;
            a.pb({x, y});
            l.pb(x); r.pb(n - y);
            m++;
            queries[i] = {2, m - 1};
        }
    }

    vector<int> ord(m, 0);
    iota(all(ord), 0);
    sort(all(ord), [&](int i, int j) {
        return a[i].second < a[j].second;
    });
    vector<int> pos(m);
    for (int i = 0; i < m; i++) pos[ord[i]] = i;
    segtree sg(m);

    for (int i = 0; i < q; i++) {
        if (queries[i].first == 0) {
            int lol = sg.get(pos[queries[i].second]);
            //cout << lol << '\n';
            cout << max(n - lol, a[queries[i].second].first) << ' ' << a[queries[i].second].second << '\n';
        } else if (queries[i].first == 1) {
            int L = -1, R = sz(ord);
            while (R - L > 1) {
                int M = (L + R) / 2;
                if (a[ord[M]].second <= queries[i].second) L = M;
                else R = M;
            }
            if (R) sg.upd(1, 0, m, 0, R, queries[i].second);
        } else {
            sg.free(pos[queries[i].second]);
        }
    }
}

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
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3840kb

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:

703152954 155393653
406191928 499382196
406191928 499382196
568874648 274309686
58956946 596540151
199070534 386549252
373137208 134433052
406191928 499382196
196862582 704927063
601883225 329807019
487677860 110879212
661256159 124128317
751624518 7040884
406191928 499382196
174003214 771291775
770...

result:

wrong answer 2nd lines differ - expected: '568874648 274309686', found: '406191928 499382196'

Subtask #2:

score: 0
Wrong Answer

Test #7:

score: 0
Wrong Answer
time: 538ms
memory: 37768kb

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:

993267240 6732751
315188472 684811456
76595172 922437952
486780435 512724930
161829967 836886041
572132261 427866716
750002500 65762937
750002500 77683574
207947130 792051536
343822470 656177426
727111507 272888421
706937632 293061330
885997292 113491348
625002500 346017967
875002500 50191019
288866...

result:

wrong answer 108th lines differ - expected: '796877500 192386301', found: '789065000 192386301'

Subtask #3:

score: 0
Wrong Answer

Test #14:

score: 0
Wrong Answer
time: 449ms
memory: 30784kb

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:

1603 999995752
311900542 626076836
353587097 582311003
135154605 823201952
1603 999995752
88429068 879554432
716432267 229484324
157875583 797283755
196566000 758913803
902622474 69540417
1603 999995752
391122000 571623281
653250000 299154784
782914000 185504610
673610863 267731597
844354000 1186645...

result:

wrong answer 1st lines differ - expected: '311900542 626076836', found: '1603 999995752'

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%