QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#536301#951. The Potion of Great Powerbachbeo2007100 ✓2112ms27176kbC++231.7kb2024-08-28 23:48:412024-08-28 23:48:41

Judging History

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

  • [2024-08-28 23:48:41]
  • 评测
  • 测评结果:100
  • 用时:2112ms
  • 内存:27176kb
  • [2024-08-28 23:48:41]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int maxn = 1e5+5;
const int T = 50;

int N,D,H[maxn];
vector<pair<int,int>> P[maxn];
vector<vector<int>> S[maxn];

void init(int _N, int _D, int _H[]) {
    N=_N,D=_D;
    for(int i=0;i<N;i++) H[i]=_H[i];
}

void curseChanges(int U, int A[], int B[]) {
    for(int i=0;i<U;i++){
        P[A[i]].push_back({B[i],i});
        P[B[i]].push_back({A[i],i});
    }

    for(int i=0;i<N;i++){
        set<int> ss;
        for(int j=0;j<(int)P[i].size();j++){
            int v=P[i][j].first;
            if(ss.count(v)) ss.erase(v);
            else ss.insert(v);
            if(j%T==0){
                vector<int> cc;
                for(int x:ss) cc.push_back(x);
                S[i].push_back(cc);
            }
        }        
    }
}

vector<int> get(int u,int t){
    int l=-1,r=(int)P[u].size()-1;
    while(l<r){
        int m=(l+r+1)>>1;
        if(P[u][m].second<t) l=m;
        else r=m-1;
    }
    if(l==-1) return {};
    int id=l/T;
    set<int> ss;
    for(int i=id*T+1;i<=l;i++){
        int v=P[u][i].first;
        if(ss.count(v)) ss.erase(v);
        else ss.insert(v);
    }
    vector<int> res;
    for(int v:S[u][id]){
        if(ss.count(v)) ss.erase(v);
        else res.push_back(H[v]);
    }
    for(int v:ss) res.push_back(H[v]);
    sort(res.begin(),res.end());
    return res;
}

int question(int x, int y, int v){
    vector<int> X=get(x,v);
    vector<int> Y=get(y,v);
    int res=inf;x=0,y=0;
    while(x<(int)X.size() && y<(int)Y.size()){
        res=min(res,abs(X[x]-Y[y]));
        if(X[x]<Y[y]) x++;
        else y++;
    }
    return res;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Accepted

Test #1:

score: 0
Accepted
time: 1ms
memory: 3604kb

input:

6 5 11 4
2 42 1000 54 68 234
0 1
2 0
3 4
3 5
3 5
1 3
5 3
0 5
3 0
1 3
3 5
0 3 4
3 0 8
0 5 5
3 0 11

output:

26
0
1000000000
14

result:

ok OK

Subtask #2:

score: 17
Accepted

Test #2:

score: 17
Accepted
time: 4ms
memory: 3764kb

input:

1000 5 1000 1000
342193948 448026910 68644316 761511684 577068963 776799602 614126976 660759502 258243854 613898142 368575258 801348635 89458455 608459729 669369634 201863593 594630866 781089225 213978379 640173687 320042281 742525519 830693620 900583020 293649535 94883655 261044700 707979709 103940...

output:

56069747
1000000000
165738269
153159426
58388807
24549439
22589683
256130665
29002709
24669017
105670080
159573046
531247682
107141668
129070223
82202987
10031385
0
20015046
101459560
125440890
83645344
121756332
40953671
6646653
509378550
79207990
96584578
277101058
19636824
33082375
103434213
1024...

result:

ok OK

Test #3:

score: 17
Accepted
time: 3ms
memory: 3692kb

input:

1000 50 1000 1000
518039137 885332783 885315093 526574137 199797296 699309467 3421382 602474589 707739340 128605817 115407106 9872600 881437345 10432432 744651444 995811074 896677811 989792856 925216421 336426578 81507059 596236367 126407841 979917257 580332201 958609996 275825863 88471687 734270341...

output:

35919057
1852681
13081351
93458984
6735
152529378
53102773
1852681
103557077
33960471
10525199
221948650
33287323
16405187
70681230
31939803
17466924
51452924
53711600
19380221
78221235
5439066
71966513
16802138
384007401
66773301
52009729
664612204
20391593
143511089
71399865
3739246
12318147
0
133...

result:

ok OK

Test #4:

score: 17
Accepted
time: 0ms
memory: 3696kb

input:

1000 500 1000 1000
271831485 380558660 86671355 750033172 441990318 769935445 95199215 997020761 888216844 841845795 981139650 214942605 143048790 488345158 71675918 778907333 18860547 523112097 547125769 177273086 241823263 447158894 581872583 501592542 450753279 106157502 731356986 979627664 54325...

output:

315464340
43354944
161026658
669418150
10615905
114844465
12429626
35078434
181144354
92948063
123195667
604084308
37838920
39475912
144686247
105663003
17000700
21465208
301609460
111950779
92693156
53460852
13334729
5641490
244759139
37980389
24837026
13769814
19789570
16073736
39941992
28285242
1...

result:

ok OK

Test #5:

score: 17
Accepted
time: 25ms
memory: 9120kb

input:

100000 500 1000 1000
712980803 15096644 215785809 554794615 546559337 214876131 417701202 175836434 836814733 808550982 639053206 46193419 251469759 356677756 939385462 606805271 555323679 304176320 560405729 182101129 89973068 39742681 718451663 679925918 302363876 438352664 766689103 261100946 653...

output:

163988458
550969991
143982564
135719007
514635217
615312904
398584403
75377161
170458688
391155847
410982864
195156159
203818053
27278677
26718334
27309154
207048486
46480049
313541194
40463625
314281060
150360715
453819986
116239154
214750527
39693115
31783732
344500099
181818850
275756935
16344248...

result:

ok OK

Subtask #3:

score: 14
Accepted

Test #6:

score: 14
Accepted
time: 231ms
memory: 22600kb

input:

100000 500 200000 50000
359427911 231219578 589241533 176630202 348497529 83909133 920296708 304849186 956464416 266371163 510421141 17422749 500931281 978026820 547329361 547408237 569681556 68625845 808353608 125013077 707708475 108464248 741397283 501550789 136881224 476037217 540822645 796887813...

output:

108165131
36950569
67785365
9767564
8191233
111753222
13429159
4093234
8445286
54642483
6042035
8729863
40557547
17118696
2778023
1573729
49417382
39324116
5951538
90171751
49039253
19521230
12937330
34442230
20377572
16729217
48908304
76315726
2809173
298864
506679983
13642209
66874653
27564632
302...

result:

ok OK

Test #7:

score: 14
Accepted
time: 259ms
memory: 22460kb

input:

100000 500 200000 50000
81242516 665909758 134832716 40360212 13706759 72390988 16956187 147579674 391688467 688934289 830907182 606251261 825151299 664334650 754562625 323235606 939456864 912161013 785222408 423042913 123020382 760416005 402426524 23327715 54672458 7458217 976462404 529305608 49213...

output:

9830253
12878069
26667685
719159
1893332
12350983
19587756
62088278
2631191
96447210
901242
2728000
55076500
87840322
61054075
36203232
17705879
19231933
27133043
19900705
50047541
10164411
21976192
127794902
16963939
11263951
9656545
165498354
126018612
1000000000
13090567
20165333
48625078
6864899...

result:

ok OK

Test #8:

score: 14
Accepted
time: 380ms
memory: 10664kb

input:

100000 500 200000 50000
795106389 548261078 359682844 672601766 587518780 964165655 589521568 132005220 930795290 417021449 891268603 796603559 138249986 20305403 912551208 865123551 549147029 632619786 30375289 852323301 132228909 854718166 131457946 738340047 899069590 245109390 215549159 27553495...

output:

17364473
6662097
80596254
14178191
19368979
2715918
2849122
2448557
0
3468706
35621357
111927
0
8316080
2976981
212216
10172316
7460786
32336893
7577487
6625118
8761206
4614827
5706372
21702474
3352566
8316080
5345749
9860783
19430243
3352566
8640302
10172316
690389
8316080
18321588
19368979
1882038...

result:

ok OK

Test #9:

score: 14
Accepted
time: 1342ms
memory: 13788kb

input:

1000 500 200000 50000
626044209 697188177 353823671 25080389 671447310 435284115 390062124 794372096 887262256 167445100 313884885 356617505 22278337 878276802 506156575 793702253 438186614 772790892 445289616 557451938 901948424 90661185 382955790 963916902 899420658 347316154 455555797 646446387 3...

output:

1004
1004
1004
3722
3722
26198
3722
26991
0
10438
3722
10438
21053
25777
4699
4699
10438
4699
25777
3722
4699
4699
10201
3722
4699
1004
6599
6599
38957
3722
5919
4699
20245
10201
10438
9340
20245
17315
30075
6599
3722
4699
5919
17315
21053
10438
26198
17315
6599
1004
6599
4699
34179
1004
34179
3722
...

result:

ok OK

Test #10:

score: 14
Accepted
time: 644ms
memory: 11412kb

input:

10000 500 200000 50000
163879682 921411837 271026594 455492456 119890885 745069173 632333793 970329217 35296032 195932765 630794020 920311416 978616689 246285133 169937786 261535947 833051156 855934512 449667498 409994780 279424588 406143064 327594906 21676865 917533086 988521259 824285470 214159414...

output:

196070
174816
53428
147557
56442
425514
414368
105598
635651
5781
153008
749911
125993
541016
37565
690134
19986
930223
312160
337833
184387
243457
441182
268217
67461
360450
247526
28806
352012
440733
171383
35049
298818
187304
1526940
442391
1078447
155514
168915
301486
380916
468975
403112
109867...

result:

ok OK

Test #11:

score: 14
Accepted
time: 2112ms
memory: 27176kb

input:

100000 500 200000 40000
718463756 420819537 142320564 981061850 609329244 702950460 54188620 402661722 996029685 93864582 63116039 986180191 558704284 258964680 10410016 370990241 406272528 131106461 526238843 86811408 17718141 858111917 666284265 648059895 238448939 35361184 229704088 798095234 112...

output:

6869
2023
4044
9241
2132
450
713
1627
1859
4375
4300
3701
1062
3142
2451
1231
2358
1776
463
5430
1245
1668
112
3310
2043
5870
412
1188
179
1260
2690
51
1523
2698
2060
2834
989
546
440
5074
3867
390
239
2736
3607
1095
856
1100
3917
2355
1239
765
1888
2019
1792
1393
3240
105
2357
5065
1794
1184
1013
1...

result:

ok OK

Test #12:

score: 14
Accepted
time: 657ms
memory: 22480kb

input:

100000 500 200000 50000
165733780 995983831 716238803 634059951 634100653 115491605 986363695 843718343 883882648 695689505 355291733 862647053 979041806 687005500 589032782 940586046 728005485 157805239 261820638 935354437 149656032 235001067 25135840 610905229 473763468 948243059 785264797 9404883...

output:

404229
77024
310909
97182
448808
85906
190698
59600
115485
61540
118424
244029
162777
25787
357040
517005
371185
10545
54167
133165
164513
294001
123107
410443
270059
8657
33406
944357
18706
95201
267792
1058204
109961
489682
135931
45151
100022
575968
111269
199602
15745
133085
191943
1354
22432
20...

result:

ok OK

Subtask #4:

score: 18
Accepted

Test #13:

score: 18
Accepted
time: 232ms
memory: 22384kb

input:

100000 500 200000 50000
1 1 1 0 1 0 1 1 0 0 0 1 1 1 0 0 0 1 1 0 1 0 0 0 1 0 0 0 1 0 1 0 1 0 0 1 1 1 0 1 1 0 0 1 1 0 1 1 1 1 1 0 1 0 1 1 0 1 1 1 1 0 1 0 0 1 1 1 1 1 1 0 1 1 1 1 0 1 0 1 0 0 0 1 0 1 0 0 0 1 1 1 1 0 1 0 1 1 1 0 0 0 1 0 0 0 1 0 1 1 1 1 1 1 1 1 0 1 1 0 1 0 1 0 0 1 0 0 0 0 0 0 0 1 0 0 0 1 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok OK

Test #14:

score: 18
Accepted
time: 1017ms
memory: 24284kb

input:

100000 500 200000 50000
0 0 1 1 1 0 0 1 0 1 0 0 0 0 1 0 0 0 1 1 0 1 0 1 0 0 1 1 0 0 0 0 0 0 1 0 0 0 1 0 1 1 0 0 1 1 0 1 0 0 0 0 1 1 0 1 1 1 0 1 1 0 1 0 0 1 0 0 1 1 0 0 1 1 0 0 0 1 0 0 1 0 1 0 1 1 1 1 0 1 0 0 1 0 0 0 1 0 0 0 1 1 0 0 0 1 1 0 0 1 1 1 1 0 1 1 1 0 0 1 1 0 1 0 0 1 0 1 1 1 1 1 0 0 1 0 1 0 ...

output:

0
0
0
1000000000
0
1000000000
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1000000000
0
0
0
1000000000
0
0
0
0
0
0
0
1000000000
1000000000
0
1000000000
0
0
0
0
0
0
0
0
1000000000
0
0
0
0
0
0
1000000000
0
0
1000000000
0
1000000000
1000000000
1000000000
0
1000000000
1000000000
0
0
0
0
0
0
1000000000
1000000000
0
0
0
0...

result:

ok OK

Test #15:

score: 18
Accepted
time: 746ms
memory: 24144kb

input:

100000 500 200000 50000
1 1 0 1 0 0 0 1 1 1 1 0 1 0 1 1 0 0 1 0 1 1 0 0 1 1 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1 1 0 0 1 1 1 1 0 1 0 1 0 0 1 1 0 1 1 1 1 0 1 1 0 1 0 1 1 0 1 0 1 1 0 0 1 1 0 1 0 0 0 1 0 1 0 0 0 0 1 1 0 1 1 0 0 1 1 1 0 0 1 1 0 1 0 1 0 0 0 1 0 0 0 0 1 0 1 1 0 0 1 0 1 0 1 1 1 0 0 1 1 1 1 1 0 1 ...

output:

0
0
1000000000
1000000000
0
0
0
0
0
0
0
0
0
1000000000
0
0
1000000000
0
0
0
0
0
0
1000000000
0
0
0
1000000000
0
0
0
0
0
0
0
0
0
0
0
0
1000000000
1000000000
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1000000000
0
0
0
1000000000
1000000000
0
0
0
0
0
0
0
0
0
1000000000
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
10000000...

result:

ok OK

Test #16:

score: 18
Accepted
time: 1086ms
memory: 26880kb

input:

100000 500 200000 50000
0 1 0 0 1 1 1 0 1 1 0 1 0 1 0 0 0 0 1 1 1 1 1 1 1 0 1 1 0 0 0 0 1 0 0 1 0 1 1 1 0 1 0 1 0 0 1 0 0 0 1 1 1 0 0 0 1 0 0 1 0 0 1 0 1 1 1 1 0 0 0 0 1 0 1 1 0 1 1 0 1 0 1 1 1 0 1 0 0 1 1 0 0 0 0 1 1 1 0 1 1 0 1 0 0 1 1 0 0 0 0 1 1 1 0 0 1 0 0 1 1 1 0 1 1 0 0 0 0 0 1 1 0 0 0 0 1 1 ...

output:

0
0
0
0
0
0
0
0
1000000000
0
0
0
1000000000
0
0
1000000000
0
0
0
1000000000
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1000000000
0
0
0
1000000000
0
0
0
0
0
0
0
1000000000
0
0
0
1000000000
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1000000000
0
0
0
0
0
0
1000000000
0
0
0
0
0
0
...

result:

ok OK

Test #17:

score: 18
Accepted
time: 347ms
memory: 22676kb

input:

100000 500 200000 50000
1 0 1 1 1 0 1 1 1 1 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 1 1 1 0 0 0 1 1 0 0 0 0 1 1 1 1 1 0 1 1 0 0 1 1 0 1 1 1 0 1 1 1 0 0 1 0 1 0 1 1 1 1 1 0 0 0 1 1 0 0 1 1 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 0 0 1 1 1 0 1 0 0 1 1 1 1 0 0 0 1 0 0 1 1 0 1 1 0 1 1 1 1 1 1 1 1 0 0 1 0 1 1 1 0 0 0 0 1 ...

output:

0
0
1000000000
0
1000000000
1
1
0
0
0
0
0
0
0
0
0
0
1000000000
0
1000000000
0
1
0
0
0
1
0
1000000000
0
1
1000000000
0
0
0
0
0
1000000000
0
0
0
1000000000
0
0
1000000000
1000000000
0
0
0
0
0
1000000000
0
0
0
0
0
1000000000
0
0
0
0
0
0
0
0
0
0
1000000000
0
0
1000000000
1000000000
0
0
0
0
0
0
0
1000000...

result:

ok OK

Test #18:

score: 18
Accepted
time: 1118ms
memory: 26904kb

input:

100000 500 200000 50000
0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 0 0 0 0 1 0 0 0 0 0 1 0 0 1 1 0 1 1 0 0 0 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 0 1 1 0 0 0 0 0 1 1 1 0 1 1 0 1 0 1 0 0 1 0 0 0 1 1 1 1 0 1 0 0 0 1 0 0 1 1 1 1 0 0 1 1 1 0 1 1 1 1 0 1 1 0 1 0 1 1 1 1 0 1 0 0 0 0 1 0 1 0 1 0 0 0 1 1 0 0 0 0 1 0 1 0 0 0 1 ...

output:

0
0
0
0
1000000000
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1000000000
0
0
1000000000
0
0
0
0
1000000000
1000000000
0
0
0
0
0
1000000000
1000000000
0
0
0
0
0
0
1000000000
1000000000
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1000000000
0
0
0
0
0
1000000000
1000000000
0
0
1000000000
1000000000
0
0
1000000000
0
0
0
0
0
0
1...

result:

ok OK

Subtask #5:

score: 21
Accepted

Test #19:

score: 21
Accepted
time: 56ms
memory: 5112kb

input:

10000 500 10000 50000
557129004 271396144 243214573 223307427 938153941 168271048 679284217 917594203 531698929 789590540 53552959 150194904 633548426 330122112 296570958 984149064 160272982 564724987 382861067 626536667 633257605 949836938 885714989 492328054 917274242 290429202 463352120 415263724...

output:

188596055
395599637
227135697
78555973
145712152
470761224
99597840
12194661
58141866
85035122
284388902
134125566
193395355
33501706
141540345
279324403
601443817
27754682
677629561
161906241
24241838
143393623
167085679
178086326
120347670
126733353
391710051
1828235
201370348
77984078
107388131
7...

result:

ok OK

Test #20:

score: 21
Accepted
time: 222ms
memory: 4692kb

input:

10000 500 10000 50000
950060719 98895632 337517308 381787945 954357434 646199487 642563569 293137500 539695138 935345522 484991396 80044643 633497772 903876926 193701202 231102871 429227591 846604210 583092782 955975620 868003333 737034715 323117555 865633604 946601945 691731050 849040808 95095225 6...

output:

31611897
1000000000
4377062
1000000000
7942597
845523
2092482
1000000000
0
2121904
3105194
1000000000
749220
2756616
0
8203689
30376434
16553186
69947780
222302064
7682652
1352299
1085580
1000000000
1000000000
9366954
24830826
286619
1000000000
1000000000
42855725
0
1000000000
5389447
1000000000
144...

result:

ok OK

Test #21:

score: 21
Accepted
time: 325ms
memory: 4744kb

input:

10000 500 10000 50000
166420045 846830930 59399262 864541017 490482997 593729222 976349404 122671155 489611859 853211209 705401799 16443884 527472673 505658038 435080064 366760889 969742616 143387269 908612598 351209707 471127209 281620560 211088393 582472861 388673447 846264595 295047486 119140906 ...

output:

16128186
2035996
840223
9637569
1317068
1000000000
731304479
0
65958
1000000000
3452093
1786469
0
9661909
0
382840
3745552
1323930
26624275
1000000000
1000000000
711650
6915715
435870
466740
3452093
1000000000
82619
4580760
2301832
0
0
7847622
1323930
711650
1000000000
0
314490
3252175
17237089
3671...

result:

ok OK

Test #22:

score: 21
Accepted
time: 873ms
memory: 5260kb

input:

10000 500 10000 50000
456174575 306711673 293651782 827904377 465109271 11836416 288269547 313739023 801911907 701410064 9234347 355951083 618642669 631287172 902708673 992233941 887850893 902852486 502592022 362662458 315861917 795190199 395117786 46817945 45800733 902924859 699943973 394725447 204...

output:

27472
68726
10516
11856
11537
15628
727671
132788
42314
249349
7024
1000000000
10819354
1000000000
46501
25920
14893
1000000000
1326099
254957
11385
101722
15628
22699
10421
10421
3465
752087470
3379
1229701
1378950
1606112
18465
1915613
1000000000
15063
33498
12873
31302
1000000000
75863
15223
4877...

result:

ok OK

Test #23:

score: 21
Accepted
time: 799ms
memory: 5144kb

input:

10000 500 10000 50000
945742237 837604412 498422463 372491470 832690836 63295296 643660456 986179952 532464037 894192755 76973823 708748285 779793041 779163950 317554697 847595767 388038478 222771726 875864309 831844625 585144551 218896982 405653666 318753535 514457120 313586287 473991873 450699500 ...

output:

1000000000
748068
0
21282
1000000000
802304
1000000000
80055636
1000000000
13579
588342
64387
1000000000
943
801
3629393
1000000000
78711
1762
13579
8477
1000000000
16921
765153046
64445
1000000000
39091629
4937
0
1238685
4278851
2166452
1000000000
1256862
1000000000
1000000000
1000000000
1000000000...

result:

ok OK

Test #24:

score: 21
Accepted
time: 209ms
memory: 4048kb

input:

1000 500 10000 50000
741707745 844758713 509784278 347637246 304521357 399811725 652424850 415374394 838581021 886181953 274198872 312721475 349561081 628075277 448281237 419125673 429687299 974297715 554897587 806802771 466252686 532277243 261729577 182910528 238562428 713821699 152148643 47452677 ...

output:

1000000000
3867772
158517
5957536
6182966
1000000000
832702
849551
6387
0
3708533
33021105
1257476
40670747
4414937
5258723
23702434
1187454
4620625
29013846
233704
263280
139665
4095536
0
771536
1008900
6732275
1972385
18769182
1698987
3126495
1889712
5140044
2011587
390008
3254931
856841
1733017
3...

result:

ok OK

Test #25:

score: 21
Accepted
time: 776ms
memory: 4852kb

input:

10000 500 10000 50000
60277018 219643583 794383196 426734066 808805171 440526065 712603579 115086775 714236942 673432841 992718949 194660730 134997204 736802272 637273410 243180956 9816188 15883719 748159138 758943033 602465116 716916602 246332413 876425156 710912647 580865443 267676053 281058947 51...

output:

12329
42713
66642
175100
3245600
66642
1000000000
16427
12329
75693
147321
338523
42713
45152
66642
195
195
1000000000
1131660
173791
31095
2572928
195
107390
6121
175100
66276
3338569
1000000000
2629877
1000000000
1000000000
195
12329
102554
15396
102554
5341455
2005445
0
9564
1000000000
16427
9564...

result:

ok OK

Subtask #6:

score: 30
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Test #26:

score: 30
Accepted
time: 827ms
memory: 20228kb

input:

100000 500 200000 50000
276715171 227937805 416134597 100202214 295936959 58707798 788314738 107538901 214103719 304522916 718166822 44768615 159262558 338424411 118365864 443917418 926992958 605371103 998771948 930133780 481004171 910034061 714878511 630153937 191294132 604500078 959507871 23463840...

output:

31735
1000000000
1000000000
14939
63597
1000000000
1000000000
1000000000
13926
1000000000
24883
1000000000
1515
1000000000
325819
0
5574
3575
1000000000
47657
6807
17968
1000000000
1000000000
4026097
1000000000
98811
1317256
4274802
203434
13974
41755
316556
39411
1000000000
21975
5766629
1000000000...

result:

ok OK

Test #27:

score: 30
Accepted
time: 1134ms
memory: 24212kb

input:

100000 500 200000 50000
235363146 536112918 34345809 116104362 112566417 61818025 731366495 575451741 55881082 732513430 45513120 781102800 617894857 413545474 137457240 35023150 68390083 352082327 60536541 219651565 331270914 486381449 356266741 988665098 575369572 27467053 190451096 524787346 3982...

output:

1000000000
8602
34052
14677
33868
22372
8124
4587
1918
1000000000
11237
421509
6973
6775
1000000000
6077
1000000000
141554
2532
124680
12140
1000000000
14432
2882
13003
1000000000
2183
104
2032714
23700
2806
128
808
1000000000
4690977
1000000000
9261
1126
73098
1000000000
13505
43721
23552
3171961
1...

result:

ok OK

Test #28:

score: 30
Accepted
time: 1156ms
memory: 24484kb

input:

100000 500 200000 50000
493765858 51738016 817500459 870043201 974897366 329230506 738250433 83383331 412262385 327304227 583264136 132654378 760054573 886996663 229345925 647387737 783541038 184152245 576581978 169392009 145818507 999297224 6405035 236263785 31199809 746775651 875929448 230501600 6...

output:

41450075
0
0
163556
15928
0
133794921
7131
3363
90582506
217
1463
356980
4266750
19415
21766
1042637
1938
280726
108
317083915
0
412
22888587
1805485
56230647
197073749
0
380967791
1000000000
0
2020553
290888
119770134
20824
5768
1052836
3960725
1000000000
0
98296620
0
3271
2396
0
395019
377390
1359...

result:

ok OK

Test #29:

score: 30
Accepted
time: 1206ms
memory: 13516kb

input:

1000 500 200000 50000
983873550 290002169 865141783 331757392 887661911 436637828 767204257 738455871 223094225 501477921 358001901 896909347 874552674 828882748 282456760 106727094 734776845 506004222 449491418 670124440 539622541 539435696 633701883 440639212 994782754 12989104 831453007 153893343...

output:

11779
0
898
16610
15778
0
0
17916
30235
13044
0
13044
9288
1425
0
898
60985
0
13044
1425
76659
0
16610
16610
31917
0
5021
1425
17767
0
898
0
898
0
9288
0
0
898
18239
13044
18239
0
15925
19792
9288
898
9288
17916
0
94243
17916
11779
1425
13044
898
898
16610
31917
16610
60985
16610
0
0
16610
13044
0
1...

result:

ok OK

Test #30:

score: 30
Accepted
time: 2063ms
memory: 26928kb

input:

100000 500 200000 50000
305096339 125860846 145903108 395587497 850513904 40521108 340085398 437229460 876757593 293517502 531193076 330840199 106947404 575745965 766035236 92613648 553765620 523243977 405169219 442483781 441317541 910124189 149282859 255244940 663285910 379856985 384664283 69373090...

output:

1000000000
6219
681
3234136
569605578
2739
3708
1000000000
2394251
4860
3807
1533
135
2422727
66
4740
5722
868
1571
1000000000
470
3332
183
640815
1000000000
540189
392198
3225
187
6704
652
5540
0
2091669
1565839
782
1357
69
939857
11598
1000000000
1000000000
1048
487041
552
488
8074
3399
984
792
73...

result:

ok OK

Test #31:

score: 30
Accepted
time: 1853ms
memory: 23824kb

input:

100000 500 200000 50000
213132627 75865178 518048654 23330397 856202603 380170543 510016850 205216753 462087450 993728682 611081169 890003000 148667586 200464781 945350459 168271718 469981431 122226155 334521080 586766650 78739329 10701632 596426604 948634635 64489038 668431463 994114159 11850988 78...

output:

946
1436
51884
59
1000000000
4063
1000000000
2731
1000000000
253
115
1000000000
2947407
643
59
4063
1000000000
7234
4840
4525
1000000000
375
1000000000
1000000000
1485
643
5391668
1000000000
1000000000
372
1000000000
1000000000
115
1000000000
1755
892928
4063
1652
3028
1000000000
946
830
1000000000
...

result:

ok OK

Test #32:

score: 30
Accepted
time: 1746ms
memory: 26960kb

input:

100000 500 200000 50000
689003022 995420080 230599524 385456891 788003096 514820638 123923684 761733805 292628000 530012233 577121860 556860478 10530914 78438222 932373937 53850050 664702902 32390660 406976382 17903514 521643422 310522098 716188144 80400218 567498122 45838957 180134155 29838731 1458...

output:

260
1000000000
547
2715
2089
4182
1134143
683
1689
54367
597708
405
9993
1000000000
1526
1000000000
9604
1100876
3731
1000000000
0
2474
1000000000
1298
9579
21576
1741
1000000000
1084
3113
1000000000
2848
1000000000
1000000000
903
679
1000000000
3962042
1000000000
1000000000
1935
1000000000
4503
779...

result:

ok OK

Extra Test:

score: 0
Extra Test Passed