QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#884366#3554. Sweepingmakrav#11 1878ms46600kbC++203.5kb2025-02-06 01:05:112025-02-06 01:05:13

Judging History

This is the latest submission verdict.

  • [2025-02-06 01:05:13]
  • Judged
  • Verdict: 11
  • Time: 1878ms
  • Memory: 46600kb
  • [2025-02-06 01:05:11]
  • 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(m), sgr(m);
    for (int i = 0; i < m; 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 + 1, 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 + 1, 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;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 3ms
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
568874648 583395188
58956946 583395188
199070534 386549252
373137208 134433052
196862582 583395188
601883225 329807019
487677860 583395188
661256159 69941943
751624518 7040884
174003214 588907149
770471768 588907149
256547879 253536990
36478325 253536990
175794127 430044359
25624...

result:

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

Subtask #2:

score: 0
Wrong Answer

Test #7:

score: 0
Wrong Answer
time: 1238ms
memory: 46600kb

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
500002500 684811456
76595172 922437952
486780435 512724930
500002500 836886041
572132261 427866716
358806418 65762937
625002500 77683574
207947130 792051536
343822470 656177426
727111507 272888421
706937632 293061330
885997292 113491348
875002500 346017967
875002500 50191019
288866...

result:

wrong answer 2nd lines differ - expected: '315188472 684811456', found: '500002500 684811456'

Subtask #3:

score: 11
Accepted

Test #14:

score: 11
Accepted
time: 1878ms
memory: 42460kb

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:

311900542 626076836
353587097 582311003
135154605 823201952
88429068 879554432
716432267 229484324
157875583 797283755
196566000 758913803
902622474 90110001
391122000 571623281
653250000 299154784
782914000 185504610
673610863 281598001
844354000 118664505
70986711 901272703
456658000 481766999
456...

result:

ok 500000 lines

Test #15:

score: 11
Accepted
time: 1710ms
memory: 42340kb

input:

1000000000 500000 1000000
711 999994527
752 999994374
2088 999992819
5223 999992787
5467 999987358
6334 999983248
6451 999982144
6867 999973271
7174 999972955
7679 999969489
7936 999963362
10108 999961505
11435 999954271
12206 999953071
12637 999952749
14297 999950070
14431 999943795
15908 999943773...

output:

627056659 310604349
525115362 409037431
11257063 981362089
897152588 73964651
406856909 574016001
98304000 888520100
806191812 163838001
938383580 41897852
541250000 450499098
15592792 974613590
672322000 294910001
934466000 52871543
111768500 885312001
454098647 541248001
737858000 257190767
564058...

result:

ok 500000 lines

Test #16:

score: 11
Accepted
time: 1123ms
memory: 42444kb

input:

1000000000 500000 1000000
0 999999941
0 999996699
0 999994719
0 999990436
0 999983997
0 999980179
0 999976969
0 999971678
0 999962276
0 999962267
0 999956799
0 999956693
0 999949116
0 999929641
0 999927891
0 999925532
0 999925306
0 999921264
0 999917061
0 999914626
0 999914073
1 999912558
1 99991037...

output:

95821691 281346275
65464239 361971306
91598049 290340860
785776891 6087358
233672440 122915495
307228231 85721547
541789827 30135863
356058819 68058743
103584154 265419153
148888293 196470767
291484151 92466823
162064257 181407656
739230653 9157967
47614983 431978395
667087014 15278664
558328216 278...

result:

ok 500000 lines

Test #17:

score: 11
Accepted
time: 1183ms
memory: 42432kb

input:

1000000000 500000 1000000
0 999991253
0 999985982
0 999953011
0 999947615
0 999946652
0 999933969
0 999933009
0 999931957
0 999917956
0 999891204
1 999869524
1 999859615
1 999856952
2 999852381
2 999850790
3 999848842
3 999842291
3 999841241
4 999824326
5 999815025
5 999813375
7 999793610
8 99976473...

output:

9435205 835911471
98690543 508351153
366866255 180785350
130349596 446629329
571209380 72682179
92613476 521778568
75834328 562191648
169195975 384632597
32630622 702876637
210953054 328164000
28595956 720444625
21346113 757074586
123191585 459622535
9154667 838216772
179776233 369297844
3836358 894...

result:

ok 500000 lines

Test #18:

score: 11
Accepted
time: 1576ms
memory: 42392kb

input:

999999999 500000 1000000
209 999939336
263 999857265
335 999353126
749 999336303
1012 999298645
1509 999255238
1516 999138117
1522 999065239
1647 998988273
1666 998959380
1708 998857952
1986 998750439
2073 998735797
2140 998715034
2197 998705656
2221 998670506
2297 998643033
2397 998621592
2585 9986...

output:

50426440 753071646
99783570 753071646
31586404 753071646
668241833 191416425
729552775 191416425
615744255 359520117
736506456 191416425
67093989 927811262
523159185 414542934
575585847 414542934
108756451 784296539
395229515 414542934
983253025 13600160
454216382 414542934
227329884 753071646
17611...

result:

ok 500000 lines

Test #19:

score: 11
Accepted
time: 1611ms
memory: 42492kb

input:

1000000000 500000 1000000
1126 999998502
1656 999992915
2282 999990802
2593 999989518
4624 999984917
5005 999982760
9195 999980284
10155 999970463
10312 999965613
11710 999965538
12557 999964206
14034 999953698
14743 999953019
15012 999951181
16555 999949593
17217 999947554
18391 999944788
19705 999...

output:

162798146 790591921
236766985 707829653
172460568 779644240
39056931 941960282
577291146 358424285
216118866 730709487
643122238 353047005
57343011 918279942
513679053 420533581
503879720 430183450
920530276 55721252
869766753 96923250
984396924 9103595
704052005 282602757
732427866 214913294
322848...

result:

ok 500000 lines

Subtask #4:

score: 0
Wrong Answer

Dependency #3:

100%
Accepted

Test #20:

score: 0
Wrong Answer
time: 1072ms
memory: 42452kb

input:

1000000000 500000 1000000
251810475 747496720
307939194 692060634
205042941 794954585
415570818 584429156
302681410 547694910
474946082 525051502
547764842 346120840
44788439 14698767
130999466 869000526
65587403 934409632
660029723 329563883
716741627 283183254
947831597 52098444
517074312 48253817...

output:

828871700 171112062
536595125 462110773
443397186 556389208
444957445 460713325
750002000 94538585
974491061 25507728
12067641 633666801
725325958 274668163
750002000 590398937
750002000 588137813
750002000 811709189
290999582 702324612
830860517 169139477
739858343 260139251
810214815 181254444
522...

result:

wrong answer 4th lines differ - expected: '500002000 460713325', found: '444957445 460713325'

Subtask #5:

score: 0
Skipped

Dependency #1:

0%