QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#449812#8597. Запити красот пiдмасивiвbashkort#25 476ms248268kbC++205.5kb2024-06-21 17:35:502024-06-21 17:35:52

Judging History

你现在查看的是最新测评结果

  • [2024-06-21 17:35:52]
  • 评测
  • 测评结果:25
  • 用时:476ms
  • 内存:248268kb
  • [2024-06-21 17:35:50]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

struct Fenwick {
    vector<ll> a;

    void init(int n) {
        a.assign(n + 1, 0);
    }

    void modify(int x, ll t) {
        for (++x; x < a.size(); x += x & -x) {
            a[x] += t;
        }
    }

    ll sum(int x) {
        ll s = 0;
        for (++x; x > 0; x -= x & -x) {
            s += a[x];
        }
        return s;
    }

    ll rangeSum(int l, int r) {
        return sum(r - 1) - sum(l - 1);
    }
};

struct Segment {
    int l = -1, r = -1;
    ll sum = 0;

    Segment() = default;
    Segment(ll x, int i) {
        sum = x, l = i, r = i + 1;
    }
    Segment(int l, int r, ll sum) : l(l), r(r), sum(sum) {
    }

    bool operator<(const Segment &oth) const {
        return sum < oth.sum;
    }
};

Segment operator+(const Segment &l, const Segment &r) {
    return l.l == -1 ? r : r.r == -1 ? l : Segment{l.l, r.r, l.sum + r.sum};
}

struct Info {
    Segment minp{}, mins{}, maxp{}, maxs{}, sum{}, maxseg{}, minseg{};
    Info() = default;
    Info(ll x, int i) {
        auto s = Segment(x, i);
        auto neutp = Segment(i, i, 0);
        auto neuts = Segment(i + 1, i + 1, 0);
        minp = min(neutp, s);
        mins = min(neuts, s);
        maxp = max(neutp, s);
        maxs = max(neuts, s);
        maxseg = max(neutp, s);
        minseg = min(neutp, s);
        sum = s;
    }
};

Info operator+(const Info &l, const Info &r) {
    if (l.minp.l == -1) {
        return r;
    }
    if (r.minp.r == -1) {
        return l;
    }
    Info res{};
    res.sum = l.sum + r.sum;
    res.minp = min(l.minp, l.sum + r.minp);
    res.maxp = max(l.maxp, l.sum + r.maxp);
    res.mins = min(r.mins, l.mins + r.sum);
    res.maxs = max(r.maxs, l.maxs + r.sum);
    res.maxseg = max({l.maxseg, r.maxseg, l.maxs + r.maxp});
    res.minseg = min({l.minseg, r.minseg, l.mins + r.minp});
    return res;
}

vector<Info> tree;
int sz = 1;

void pull(int x) {
    tree[x] = tree[x << 1] + tree[x << 1 | 1];
}

void init(int n, const vector<ll> &a) {
    sz = 1 << __lg(n) + !!(n & (n - 1));
    tree.assign(sz << 1, {});
    for (int i = 0; i < n; ++i) {
        tree[i + sz] = Info(a[i], i);
    }
    for (int i = sz - 1; i > 0; --i) {
        pull(i);
    }
}

void tmodify(int x, const Info &v) {
    for (tree[x += sz] = v; x >>= 1; ) {
        pull(x);
    }
}

Info rangeSum(int l, int r) {
    Info lhs{}, rhs{};
    for (l += sz, r += sz; l < r; l >>= 1, r >>= 1) {
        if (l & 1) lhs = lhs + tree[l++];
        if (r & 1) rhs = tree[--r] + rhs;
    }
    return lhs + rhs;
}

int findFirst(int x, int l, ll hi, ll lo, ll sum) {
    if (tree[x].minp.sum + sum > lo && tree[x].maxp.sum + sum < hi || tree[x].sum.r <= l) {
        return -1;
    }
    if (x >= sz) {
        return x - sz;
    }
    int res = findFirst(x << 1, l, hi, lo, sum);
    if (res == -1) {
        return findFirst(x << 1 | 1, l, hi, lo, sum + tree[x << 1].sum.sum);
    }
    return res;
}

int findLast(int x, int r, ll hi, ll lo, ll sum) {
    if (tree[x].sum.l == -1 || tree[x].mins.sum + sum > lo && tree[x].maxs.sum + sum < hi || tree[x].sum.l >= r) {
        return -1;
    }
    if (x >= sz) {
        return x - sz;
    }
    int res = findLast(x << 1 | 1, r, hi, lo, sum);
    if (res == -1) {
        return findLast(x << 1, r, hi, lo, sum + tree[x << 1 | 1].sum.sum);
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, q;
    cin >> n >> q;

    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    bool allp = *min_element(a.begin(), a.end()) >= 0;

    Fenwick fn;
    fn.init(n);
    for (int i = 0; i < n; ++i) {
        fn.modify(i, a[i]);
    }

    init(n, a);

    auto query = [&](int l, int r) -> ll {
        ll ans = abs(fn.rangeSum(l, r)); // 1 block
        if (allp) {
            return ans;
        }
        auto info = rangeSum(l, r);
        for (int p : {info.maxp.r, info.minp.r}) {
            ans = max(ans, min(abs(fn.rangeSum(l, p)), abs(fn.rangeSum(p, r))));
        }
        auto check = [&](ll mid) {
            ll sx = fn.rangeSum(0, l);
            ll sy = fn.rangeSum(r, n);
            int i1 = findFirst(1, l, mid + sx, -mid + sx, 0) + 1;
            if (i1 == 0 || i1 >= r) {
                return false;
            }
            int i2 = findLast(1, r, mid + sy, -mid + sy, 0);
            if (i2 == -1 || i2 <= i1 || i2 >= r) {
                return false;
            }
            auto f = rangeSum(i1, i2);
            if (f.minseg.sum <= -mid || f.maxseg.sum >= mid) {
                return true;
            } else {
                return false;
            }
        };
        ll lo = ans, hi = ans + 100;
        while (lo + 1 < hi) {
            ll mid = lo + hi >> 1;
            if (check(mid)) {
                lo = mid;
            } else {
                hi = mid;
            }
        }
        ans = max(ans, lo);
        return ans;
    };

    auto modify = [&](int i, int x) {
        fn.modify(i, x - a[i]);
        a[i] = x;
        tmodify(i, Info(a[i], i));
        allp &= x >= 0;
    };

    while (q--) {
        int type, l, r;
        cin >> type >> l >> r;
        if (type == 1) {
            cout << query(l - 1, r) << '\n';
        } else {
            modify(l - 1, r);
        }
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 4
Accepted

Test #1:

score: 4
Accepted
time: 377ms
memory: 248156kb

input:

1000000 1000000
548734664 631285694 511074814 185066089 177199147 524740185 143108778 954318193 103939390 194933972 126964310 977448144 188825490 775722231 460775045 254691982 436971964 566341931 148211711 74910105 923734998 440021758 474275150 717904448 680353276 612974499 712145218 300908726 34722...

output:

251801387395338
230985543990378
233364582761908
165509624203582
383254838720986
448483728625094
365779189638223
259921744673457
396032911262151
463175787332481
396490494773605
379294045009719
380905359946099
248640668979163
372751657582612
250611799614193
382671202614963
249747705028859
377678676465...

result:

ok 1000000 numbers

Test #2:

score: 0
Accepted
time: 431ms
memory: 248092kb

input:

1000000 1000000
990113895 993892498 998227668 999901378 999927530 999967151 999984400 999995999 999997829 999997900 999998862 999999773 999999868 999999949 999999971 999999980 999999984 999999997 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 10000...

output:

517388975548697
583250844300324
432944007956879
651986171831501
542238696573424
441761501786754
330123013631473
870241324122629
883396218117077
408105370042427
707816626704213
508232505211911
739818893951077
766666985527682
465224901247448
886122292332962
914658373213235
421779818564551
727905274312...

result:

ok 1000000 numbers

Test #3:

score: 0
Accepted
time: 428ms
memory: 248084kb

input:

1000000 1000000
141598548 830665328 993488224 999755561 999945155 999986513 999989333 999990586 999994476 999997209 999998165 999998359 999998707 999999473 999999852 999999930 999999938 999999963 999999965 999999981 999999996 999999998 1000000000 1000000000 1000000000 1000000000 1000000000 100000000...

output:

356173976182880
480636735678882
715649266153211
296099114480174
495577657145300
880164857057696
360829708390397
893190933168525
659770218871691
260229819810974
825160619301796
709264679095607
588830530083195
520438551091261
655451391395164
578240261246493
212576955707985
725338244461847
416476415692...

result:

ok 1000000 numbers

Test #4:

score: 0
Accepted
time: 365ms
memory: 247996kb

input:

1000000 1000000
777974618 985268992 996078973 997554180 997788695 999658168 999968830 999980473 999998143 999999812 999999826 999999905 999999953 999999974 999999990 999999992 999999996 999999998 999999999 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100000...

output:

614388727692563
649626175674650
200543340460644
429537231405728
430189231405728
716472378936104
565372458226305
594699593996257
564844859199650
644148647862746
747289687203253
561010517064553
468050674466851
357068282778875
437757064198385
414636189013152
380245538829532
598461229740399
261190443589...

result:

ok 1000000 numbers

Test #5:

score: 0
Accepted
time: 425ms
memory: 248268kb

input:

1000000 1000000
377309365 894144488 921143445 991660683 995450636 995556635 999173866 999401820 999822658 999976711 999993812 999999725 999999817 999999968 999999992 999999996 999999998 999999999 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 10000...

output:

650552155322823
369803954654729
813016884061089
583669437559348
846050884061089
891397884061089
597163155322823
501082437559348
407475954654729
745849437559348
777099884061089
766289884061089
246508728738266
779717884061089
575586954654729
748072437559348
470318708821082
417518708821082
323575954654...

result:

ok 1000000 numbers

Test #6:

score: 0
Accepted
time: 359ms
memory: 248080kb

input:

1000000 1000000
607026608 839552936 931303147 946375702 979264955 989112811 991854785 994078939 997321934 997703417 999932023 999934524 999987158 999987867 999996003 999996883 999997617 999998635 999999062 999999992 999999995 999999997 1000000000 1000000000 1000000000 1000000000 1000000000 100000000...

output:

403158000000000
716622000000000
582130000000000
452232000000000
773107000000000
671339000000000
640401000000000
402688000000000
341097000000000
373220000000000
382028000000000
476739000000000
764869000000000
443808000000000
790093000000000
650563000000000
824479000000000
667243000000000
796546000000...

result:

ok 1000000 numbers

Subtask #2:

score: 0
Wrong Answer

Test #7:

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

input:

1000 1000
-873807720 -737050877 797489760 406646247 -750849890 -581119106 43724194 -931326234 -9389547 -684003608 -926307185 -502569356 -461635706 -238087464 -83909772 -884633970 46721429 -576741985 -323890970 -855342249 -736506813 336516318 -4075924 -782227362 56799828 290931118 -471600723 81594380...

output:

9772834244
7971661681
7251185652
5902581650
12301584130
9137214347
10770040139
9693548841
12636393268
9951777555
8590138425
9126178404
8438322412
10469973494
9585010202
12336530829
12305905331
12818655084
9576894451
9228532410
10060968297
12060843219
8619457836
8862797014
12336530829
6408306273
9621...

result:

wrong answer 44th numbers differ - expected: '5882777912', found: '4307081872'

Subtask #3:

score: 10
Accepted

Test #14:

score: 10
Accepted
time: 476ms
memory: 63676kb

input:

200000 200000
580139218 -783262026 565291185 -701435432 -591602198 -342573855 -900284959 -10919966 -682899137 -282058183 963121871 491072571 691886927 761414760 -828585515 888361166 -790814084 145385324 214735368 388759807 -80339362 -975535748 522135695 301673442 36714481 785639770 319723485 1098009...

output:

351460487491
210343422436
312498498649
203192986383
287815765786
245818714404
213968420688
159327542896
169009698075
212975612931
197610853645
255310400798
318802499824
292657635865
313528174745
321957839407
262317902055
187559666100
220264896012
221468083688
294234309666
310907237863
189575747002
1...

result:

ok 200000 numbers

Test #15:

score: 0
Accepted
time: 365ms
memory: 63532kb

input:

200000 200000
216963970 895963907 970921505 973720179 985811250 998640537 999103413 999661484 999729609 999942450 -821783874 781997309 829131735 832477333 892292610 985929024 998231319 999101470 999204347 999373872 473465706 768624229 994843197 999760281 999881158 999973657 999988928 999993358 99999...

output:

112621847444942
101030183697291
63233054628753
80384063266952
115039837711512
95578572948651
143407295417810
60640420205729
72326537106317
97513628293662
111552624754764
88836367993245
60834804129630
81553727338901
100409741576180
65344377179665
95711093922326
112060888712228
73442129454981
65507735...

result:

ok 200000 numbers

Test #16:

score: 0
Accepted
time: 369ms
memory: 63556kb

input:

200000 200000
-824647563 -226311394 73090714 76436719 759867982 803623373 829644660 946127786 957102501 987106779 997539215 999943331 999979160 999991880 999996009 999997678 999999024 999999063 999999274 999999406 999999496 999999684 999999952 999999985 999999992 999999993 999999996 999999998 999999...

output:

107254718306887
59985268718865
160651387958961
113576472431692
94922328063875
159793953406254
103324138822766
134824989111115
123862745746950
169491678824442
91501549032165
99093005632887
139347712481764
122330217459374
84161090195491
89777898364239
162149696406419
120396086999264
88322334520469
615...

result:

ok 200000 numbers

Test #17:

score: 0
Accepted
time: 370ms
memory: 63668kb

input:

200000 200000
-282183530 -94945479 227825325 604182067 992536174 995235520 999623224 999831612 999944208 999969121 999974356 999980957 999988940 999994107 999995968 999998154 999999531 999999584 999999922 999999935 999999969 999999985 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000...

output:

123377619867900
100211431195321
145963538594998
190203444064019
64843966674700
77549625539887
184560557631975
39023969105634
110224991478919
60057393127515
82953877723644
86412104386226
160532783809484
121422800259115
193867540418057
93054646076494
162102767313085
35476495087574
102656767657861
8893...

result:

ok 200000 numbers

Test #18:

score: 0
Accepted
time: 370ms
memory: 63528kb

input:

200000 200000
895486773 904267709 971843319 989242035 997432691 998747539 999923993 999958496 999981782 999997130 999998160 999999003 999999967 999999992 999999996 999999997 999999999 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100000...

output:

107947399476523
162249388524327
188244246063420
149188588881854
157732011675993
143224891836264
133208454676491
163999809906499
141125758850610
129080307951204
119938099343301
102187458820136
42426020657946
113901944910560
54823208026881
147838531324875
119767412026628
157136338370764
34461988892014...

result:

ok 200000 numbers

Test #19:

score: 0
Accepted
time: 358ms
memory: 63524kb

input:

200000 200000
15691546 982710368 991752623 996635863 999985515 999992516 999995094 999999596 999999991 999999999 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 ...

output:

72523839838926
125348292306559
156051487951881
110134134212103
157069281441772
82917291584024
119805834008914
161199487951881
118949623834329
129858684120921
104031770661480
135286708593556
136516858580023
60306452467633
70864365507686
134657502564275
83413848621308
164520131445345
125642684120921
1...

result:

ok 200000 numbers

Test #20:

score: 0
Accepted
time: 357ms
memory: 63552kb

input:

200000 200000
-90259554 929646040 932381231 965326126 992162797 999519149 999868148 999979048 999996345 999998606 999999942 999999998 999999998 999999999 999999999 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000...

output:

165849002394680
130735002394680
156026002394680
127391002394680
107616002394680
119917002394680
68572000000000
125579002394680
168319002394680
145634002394680
124946002394680
120901002394680
151983002394680
118365002394680
134173002394680
77681002394680
117765002394680
126867002394680
12318900239468...

result:

ok 200000 numbers

Subtask #4:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 394ms
memory: 63640kb

input:

200000 200000
128744308 920701830 -482412021 59142239 721167306 -622861403 165749748 -449445968 -760679479 -207234657 171482190 -239316743 75518499 -717652242 502074875 -731242646 -183939818 -625333917 -53052313 185734819 -780000096 -563390882 -690210905 596581513 764466021 776717157 -38544163 -7898...

output:

128744308
1049446138
567034117
626176356
1347343662
724482259
890232007
906557623
1347343662
1347343662
1347343662
1347343662
1347343662
1347343662
1347343662
1466264164
1650203982
2275537899
2328590212
2142855393
2922855489
3486246371
4176457276
3579875763
2815409742
2137764691
2099220528
286704480...

result:

wrong answer 71st numbers differ - expected: '3002133635', found: '2435794609'

Subtask #5:

score: 11
Accepted

Test #28:

score: 11
Accepted
time: 329ms
memory: 63524kb

input:

200000 200000
3 -5 -3 3 3 -5 7 -2 2 -4 -4 9 0 -4 -2 2 -5 7 -2 3 -8 1 6 -7 9 -3 -2 4 -2 -2 3 -2 1 0 -3 6 0 -6 -2 6 -5 6 -4 3 2 -4 5 -2 -8 1 1 2 1 -3 3 5 -9 1 3 -2 0 1 -2 1 2 5 -1 -4 -1 -3 7 -7 7 1 -6 7 -1 -5 1 4 -7 6 -3 -4 -1 4 1 5 -7 -3 9 1 -6 2 -3 1 6 -1 -1 1 -1 -5 -3 9 -5 4 -1 3 -2 -4 -4 8 1 0 -9 ...

output:

9
7
8
7
8
6
5
7
9
9
7
9
6
6
9
6
8
9
9
5
6
7
5
7
6
6
5
7
8
6
6
7
5
7
7
7
5
9
7
6
9
5
8
10
5
8
7
8
5
5
8
7
7
6
6
8
6
6
9
7
8
5
6
5
8
6
6
5
5
9
8
5
7
6
7
7
6
6
5
7
6
6
6
6
6
7
9
9
8
9
7
6
6
9
9
7
8
5
9
6
7
8
9
8
9
9
8
8
5
6
8
8
6
6
6
6
6
5
9
6
6
8
9
5
9
6
6
5
7
5
10
7
5
5
6
8
6
8
7
5
6
9
6
5
10
8
8
6
6...

result:

ok 200000 numbers

Test #29:

score: 0
Accepted
time: 321ms
memory: 63524kb

input:

200000 200000
1 2 -5 0 5 -4 4 -3 -3 0 8 -2 -8 5 2 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
6
5
9
6
7
10
8
7
7
6
10
8
6
6
8
6
5
9
6
7
7
10
6
6
7
5
7
10
8
9
7
8
8
6
7
5
8
5
8
6
5
5
9
5
7
6
8
6
5
9
6
6
8
6
7
5
6
8
6
5
6
6
7
6
5
8
6
7
7
6
8
6
7
9
8
6
7
9
6
8
8
6
...

result:

ok 200000 numbers

Test #31:

score: 0
Accepted
time: 350ms
memory: 63544kb

input:

200000 200000
4 -7 4 -3 -2 5 3 -6 -1 -2 2 7 -3 -2 1 -5 6 4 -1 -3 -6 0 5 -2 -3 0 9 -3 -2 2 -1 -1 3 2 -8 1 6 -3 5 -6 -1 -1 3 -1 2 -3 4 2 -1 -5 -3 0 3 -3 2 3 -4 8 -2 -2 0 -1 1 -3 3 -5 9 -5 0 6 -8 2 -3 0 1 3 0 2 -5 4 3 -3 -5 1 7 -1 -2 -4 -1 6 0 -1 -2 4 -4 -2 -1 8 -1 1 0 0 -9 6 1 -2 3 -2 -3 1 3 2 -1 0 -6...

output:

6
6
6
9
6
6
5
7
6
7
7
9
5
9
5
5
9
6
8
5
9
6
8
7
7
7
5
5
7
8
6
8
9
8
8
8
6
6
5
8
7
9
9
5
6
7
9
5
7
5
8
7
8
6
7
5
8
6
6
8
6
5
10
5
9
8
10
9
8
9
7
9
6
6
6
6
9
5
6
7
7
5
8
6
9
5
6
5
6
7
9
6
7
8
5
9
7
8
7
7
6
5
8
6
8
7
7
8
6
7
8
9
6
6
8
7
6
8
6
7
6
7
9
7
6
9
7
6
6
8
5
6
6
9
10
8
8
7
5
9
9
8
7
6
6
7
8
6
6...

result:

ok 200000 numbers

Test #32:

score: 0
Accepted
time: 323ms
memory: 63524kb

input:

200000 200000
-5 6 4 -7 1 -2 5 -5 7 -6 -2 0 5 2 -2 0 0 -6 1 0 6 1 1 -4 0 3 -2 0 -5 4 -3 0 6 1 -8 4 -4 2 -3 10 -7 5 -3 -4 4 -3 3 -1 1 -5 0 3 7 -10 7 -2 -2 2 -3 3 -4 8 -6 4 -2 3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5
6
9
8
6
7
6
7
6
6
6
8
6
7
6
8
8
8
5
...

result:

ok 200000 numbers

Test #34:

score: 0
Accepted
time: 345ms
memory: 63744kb

input:

200000 200000
-2 5 -6 8 -2 -8 8 -8 2 5 -7 0 8 -1 0 -2 -4 4 -5 1 7 0 -8 6 -5 0 -1 9 -3 2 -8 5 -5 8 -6 8 -2 -2 -6 1 4 0 -5 7 -6 2 2 -2 5 -7 8 1 -6 1 -5 3 6 -8 -1 5 5 -10 5 0 1 0 -1 -2 2 -1 2 3 -9 1 2 -2 2 -3 10 -7 -2 3 2 4 -10 8 -1 0 1 -8 9 1 -9 9 -3 -2 -2 2 -1 -3 4 3 -4 5 1 -7 2 -1 5 -2 1 -7 5 2 2 -1...

output:

6
6
8
9
5
6
5
6
6
7
9
6
5
8
6
6
6
7
6
6
8
6
5
7
9
8
6
7
8
8
5
8
6
8
6
6
10
7
7
6
6
5
5
7
8
6
5
5
9
8
6
6
6
6
6
6
5
9
8
8
6
6
7
6
9
8
5
6
9
6
6
6
7
9
9
9
5
10
5
7
5
7
5
6
6
8
7
6
8
6
10
7
6
5
5
9
6
7
8
5
6
7
7
8
8
7
8
7
5
5
7
8
6
6
7
7
7
7
5
6
6
5
8
6
5
7
5
7
7
7
5
6
5
7
7
7
8
9
5
5
6
8
7
6
8
5
8
5
8...

result:

ok 200000 numbers

Subtask #6:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #7:

score: 0
Skipped

Dependency #6:

0%

Subtask #8:

score: 0
Skipped

Dependency #6:

0%

Subtask #9:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%