QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#859264#9676. AncestorsShumomo17 937ms71972kbC++143.5kb2025-01-17 16:53:462025-01-17 16:53:46

Judging History

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

  • [2025-01-17 16:53:46]
  • 评测
  • 测评结果:17
  • 用时:937ms
  • 内存:71972kb
  • [2025-01-17 16:53:46]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define tm asdfdfg
int n,B,N,m,l,r,u,tm,mp,mm,tt,tmp,tot,d[100009],f[100009],g[100009],h[100009],v[100009],lg[200009],dfn[100009],ans[1000009],st[200009][22],ts[200009][22];
set<int> s[100009];
set<int>::iterator it;
vector<int> to[100009];
struct node{
    int l,r,x,id;
    bool operator < (const node aa)const{
        return l/B<aa.l/B||(l/B==aa.l/B&&r<aa.r);
    }
}q[1000009];
void add(int x){
    it=s[d[x]].lower_bound(dfn[x]);
    tmp=d[x];
//    cout<<x<<" "<<d[x]<<" "<<tmp<<endl;
    if(it!=s[d[x]].end()){
        tm=*it;
        tt=lg[tm-dfn[x]+1];
        mp=min(st[dfn[x]][tt],st[tm-(1<<tt)+1][tt]);
        tmp=min(tmp,d[x]-mp);
//        cout<<x<<" "<<d[x]<<" "<<tmp<<endl;
    }
    if(it!=s[d[x]].begin()){
        it--;
        tm=*it;
        tt=lg[dfn[x]-tm+1];
        mp=min(st[tm][tt],st[dfn[x]-(1<<tt)+1][tt]);
        tmp=min(tmp,d[x]-mp);
//        cout<<x<<" "<<d[x]<<" "<<tmp<<" "<<tm<<" "<<mp<<" "<<dfn[x]<<" "<<tt<<" "<<st[2][2]<<endl;
    }
    s[d[x]].insert(dfn[x]);
    g[x]=tmp-1;
    for(int i=n+1-g[x];i<=n+1;i+=(i&(-i)))v[i]++;
}
void del(int x){
    s[d[x]].erase(dfn[x]);
    for(int i=n+1-g[x];i<=n+1;i+=(i&(-i)))v[i]--;
}
void dfs(int x){
    st[++tot][0]=d[x];
    dfn[x]=tot;
    for(auto i:to[x]){
        d[i]=d[x]+1;
        dfs(i);
        st[++tot][0]=d[x];
    }
}
int main(){
    scanf("%d%d",&n,&m);
    B=1ll*n*n/sqrt(m);
    B=sqrt(B);
//    cerr<<B<<endl;
    for(int i=1;i<=n;i++){
        scanf("%d",&u);
        ts[i][0]=u;
        to[u].emplace_back(i);
    }
    for(int i=1;i<=m;i++){
        scanf("%d%d%d",&q[i].l,&q[i].r,&q[i].x);
        q[i].id=i;
    }
    sort(q+1,q+m+1);
    tot=-1;
    dfs(0);
    lg[1]=0;
    N=n<<1;
    N--;
    for(int i=2;i<=N;i++)lg[i]=lg[i>>1]+1;
    for(int i=1;i<=lg[N];i++){
        for(int j=1;j+(1<<i)<=N;j++){
            st[j][i]=min(st[j][i-1],st[j+(1<<(i-1))][i-1]);
        }
    }
    for(int i=1;i<=lg[n];i++){
        for(int j=1;j<=n;j++){
            ts[j][i]=ts[ts[j][i-1]][i-1];
        }
    }
    l=1;
    r=0;
    q[0].l=0xc0c0c0c0;
    for(int i=1;i<=m;i++){
        if(q[i].l/B==q[i].r/B){
//            cout<<q[i].l<<" "<<q[i].r<<" "<<q[i].x<<endl;
            tmp=0;
            for(int j=q[i].l;j<=q[i].r;j++){
                h[j]=j;
            }
            for(int j=lg[q[i].x];j>=0;j--){
                if(q[i].x&(1<<j)){
                    for(int k=q[i].l;k<=q[i].r;k++){
                        h[k]=ts[h[k]][j];
                    }
                }
            }
            f[0]=i;
            for(int j=q[i].l;j<=q[i].r;j++){
                if(f[h[j]]<i){
                    f[h[j]]=i;
                    tmp++;
                }
            }
            ans[q[i].id]=tmp;
            continue;
        }
        if(q[i].l/B!=q[i-1].l/B){
            for(int j=1;j<=n+1;j++){
                v[j]=0;
                set<int> t;
                swap(s[j],t);
            }
            mm=q[i].l/B*B+B;
            r=mm-1;
        }
        l=mm;
        while(l>q[i].l){
            l--;
            add(l);
        }
        while(r<q[i].r){
            r++;
            add(r);
        }
        tmp=0;
        for(int j=n+1-q[i].x;j;j-=(j&(-j)))tmp+=v[j];
        ans[q[i].id]=tmp;
        while(l<mm){
            del(l);
            l++;
        }
    }
    for(int i=1;i<=m;i++){
        printf("%d\n",ans[i]);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 11
Accepted
time: 1ms
memory: 20312kb

input:

7 5
3 1 0 5 3 5 1
1 3 1
5 7 2
1 5 1
4 7 1
4 7 2

output:

2
1
3
3
1

result:

ok 5 number(s): "2 1 3 3 1"

Test #2:

score: 0
Wrong Answer
time: 1ms
memory: 18356kb

input:

1000 1000
686 337 192 336 405 0 108 485 350 762 258 780 179 939 25 657 571 662 119 786 604 224 935 494 685 575 369 178 249 740 954 204 598 592 68 771 498 86 55 38 298 704 239 292 993 286 16 813 719 187 14 476 792 49 944 52 227 720 310 470 900 243 663 950 627 300 728 189 45 610 673 548 873 95 48 841 ...

output:

467
72
672
143
391
602
463
35
781
855
291
435
985
208
936
593
348
678
45
758
474
679
584
624
737
747
270
72
69
29
5
15
57
10
9
16
87
162
19
217
232
24
178
334
103
139
293
400
299
351
529
632
592
296
640
678
715
708
52
465
322
731
2
573
992
356
809
0
278
31
17
354
75
45
77
400
584
420
682
7
11
577
67...

result:

wrong answer 1st numbers differ - expected: '452', found: '467'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #30:

score: 0
Wrong Answer
time: 161ms
memory: 42720kb

input:

50000 200000
42574 43129 47328 17982 40521 6668 12729 32377 201 11940 8599 11734 18349 41045 26854 22540 9897 33419 7463 1243 47272 27135 49050 49111 22435 42539 39924 20272 5843 9308 45963 3283 31185 13692 38952 20583 15885 24802 4773 953 49907 28689 36942 23550 19449 8970 33340 31665 5407 46023 18...

output:

12072
1327
12370
2475
32809
37028
39185
31040
16761
16995
48336
42266
24077
1825
19174
7069
27509
30915
9298
17017
40463
31502
23214
8070
4021
36889
18667
6870
13467
25014
12480
17705
26332
12391
4251
2389
41200
14194
31780
26412
43116
38273
41276
23016
13035
45955
49523
19874
26233
30012
48616
4673...

result:

wrong answer 1st numbers differ - expected: '12045', found: '12072'

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 17
Accepted

Test #67:

score: 17
Accepted
time: 937ms
memory: 71772kb

input:

100000 1000000
6457 23693 90928 23592 90440 75018 16865 3342 83718 16731 95103 31510 38719 27886 29093 41955 6596 46409 51839 10527 91993 61074 14405 34833 53674 42363 11490 43757 46191 6058 59164 96938 57858 40178 97523 84164 21582 72243 11267 47368 97058 6637 95208 60092 53943 16441 28363 64965 52...

output:

52956
18767
1319
13405
11021
455
50595
81481
6813
3640
58937
10991
70
4713
36
9517
39731
1166
67346
74637
2667
45182
4914
6774
1625
4198
52270
30435
60137
48654
29768
2815
6846
73091
21944
49693
9923
46795
29787
6866
2435
20773
2959
34666
4377
2428
4582
7527
38292
7253
3586
63817
28075
43828
20215
1...

result:

ok 1000000 numbers

Test #68:

score: 17
Accepted
time: 916ms
memory: 71972kb

input:

100000 1000000
82160 95864 48267 17482 19568 35077 14202 20440 4649 64145 148 2227 6969 39096 36508 20991 67700 90300 69215 57284 18492 9246 9629 7538 7845 30368 55600 48445 18542 41242 45052 25380 20894 91677 77040 73134 15572 21966 25343 14501 16227 23870 39207 50024 30787 11148 16884 63700 33205 ...

output:

44469
16565
2546
424
43423
23219
20745
3045
35596
11249
3763
322
27634
52470
20391
28546
14538
26343
9739
15234
20199
4332
1072
43633
3512
1432
47918
11347
4284
9054
6824
9773
39448
19949
18592
16534
43419
3303
11308
51071
1613
30619
8351
15408
6155
28590
13050
10085
2851
15353
33854
11870
5231
3742...

result:

ok 1000000 numbers

Test #69:

score: 17
Accepted
time: 877ms
memory: 70424kb

input:

100000 1000000
25194 62545 57529 6618 90347 4663 56805 81144 16504 79307 43199 91078 67805 33396 46754 26525 75274 39333 20904 40286 76299 83579 79770 37838 8666 33691 40228 71445 16473 53091 68958 32037 72079 38640 89820 67042 68888 34997 65595 87669 425 95432 78811 30382 34738 51750 96653 87265 96...

output:

8417
8694
11361
18174
35962
18154
12865
15343
20557
3347
1471
13539
3932
8790
18648
6347
6750
15815
15254
27157
8688
2879
18
9789
18477
3458
17955
3648
11622
6554
6912
26184
14239
5131
9324
11512
12379
2347
2070
15793
33946
14861
30678
5093
21318
4920
2406
14339
13174
5540
8462
20728
32471
22062
151...

result:

ok 1000000 numbers

Test #70:

score: 17
Accepted
time: 802ms
memory: 68880kb

input:

100000 1000000
33869 32276 67595 11863 43366 78922 82984 33614 3349 89624 72004 26796 43181 99767 17557 34237 17402 67395 90333 32805 48065 18758 67335 51494 27849 40763 26396 34814 4622 83315 72679 97608 72899 60645 56697 71509 56066 31804 62175 73302 88129 16166 65481 42106 75805 6462 59931 64760 ...

output:

6810
8197
6684
8043
2294
1406
13501
366
6028
1200
11507
328
13178
3321
11894
9927
9616
6071
10736
21275
4465
5411
903
11738
2443
15750
6410
2417
17055
17971
18738
4022
604
14999
10200
2271
13714
14394
12211
2969
356
784
5710
7696
1207
14917
2663
13712
204
11649
17149
6685
1246
17528
1004
2737
19239
...

result:

ok 1000000 numbers

Test #71:

score: 17
Accepted
time: 731ms
memory: 66396kb

input:

100000 1000000
20202 95937 59388 22656 52438 32930 5034 5828 47736 1136 86325 30517 98060 3065 87038 7780 79252 23357 30657 39367 65318 82229 57604 36401 60931 35094 22631 8808 73815 59982 13375 6858 21054 24430 58627 54098 50600 60606 29357 14070 86046 26517 36726 52335 67979 76357 5601 23089 31084...

output:

8080
10613
4850
10949
1751
9724
3125
8953
7890
67
8939
9100
2555
3819
8351
6568
8400
5441
5389
7174
6213
192
9432
7100
8163
5061
301
2795
3245
1188
5631
2052
10101
6949
3562
3684
415
9990
9144
9728
6146
8696
9498
1323
2394
5737
7300
4857
230
205
2140
5777
10893
7591
7926
4528
10783
849
1105
4041
207...

result:

ok 1000000 numbers

Test #72:

score: 17
Accepted
time: 673ms
memory: 68336kb

input:

100000 1000000
32714 36692 31083 85620 49990 97881 7729 99744 40147 35697 60981 26710 5344 89140 82549 16186 23397 99781 1198 13479 97345 76067 11166 3816 31696 12712 86322 42387 91034 73311 30204 90186 10698 3027 90469 39773 32444 90557 38037 2811 1511 99399 82904 95751 88183 46088 2411 36754 55537...

output:

1651
603
4225
5306
397
1391
3536
2046
1766
490
4958
2050
4696
805
1761
2739
447
5839
4695
3436
4328
5745
3473
250
416
5155
4610
4209
1642
2759
33516
191
4150
227
2878
2211
1566
1426
4102
3894
862
5730
3712
284
2405
4794
1137
2228
1433
2714
3179
3730
5441
2064
1789
510
2117
3292
3637
5031
4231
123
18...

result:

ok 1000000 numbers

Test #73:

score: 17
Accepted
time: 656ms
memory: 68148kb

input:

100000 1000000
36665 34048 13767 33770 62077 34740 89600 80503 52776 40093 32294 4636 89965 40716 66459 28480 98172 65499 75307 50198 69522 69117 76142 43885 44253 95772 9808 24606 44782 232 53978 39817 47787 64598 64212 62212 95626 12362 43307 53664 69332 64445 43969 92373 79331 70902 8966 94532 70...

output:

172
2579
2057
370
587
357
2956
1810
2642
1698
1030
2438
1575
716
1289
465
290
746
251
544
2492
1082
1677
1712
140
358
2273
3595
1830
833
205
1282
1507
1036
2447
790
2637
1914
179
2660
1097
2213
3222
2898
2749
1224
1753
1913
1195
1034
2684
1729
1521
1823
2383
1378
992
2976
1018
173
947
1419
158
60
21...

result:

ok 1000000 numbers

Test #74:

score: 17
Accepted
time: 623ms
memory: 65664kb

input:

100000 1000000
25285 42985 85118 92894 42132 44140 53975 26689 61784 14964 16282 25047 75597 64954 5953 94806 31813 46882 99124 69274 16563 99491 48901 49282 93968 37463 87063 44721 80224 27813 69865 92499 37290 89151 9013 14686 53743 22181 97387 1651 98349 83530 72377 18130 14740 56916 51137 96409 ...

output:

559
2183
553
1868
835
705
969
689
758
913
1287
549
515
224
62
1326
98
22
1292
91
1349
1137
766
1376
1018
1264
412
504
1315
8326
1339
946
479
1370
666
824
1207
1283
1052
1248
483
279
616
713
1035
1238
267
454
232
520
63
729
989
935
459
925
1073
820
1258
806
582
876
952
1020
840
25
794
7954
476
532
13...

result:

ok 1000000 numbers

Test #75:

score: 17
Accepted
time: 569ms
memory: 65888kb

input:

100000 1000000
45641 92812 19273 534 22918 95339 49623 85082 11614 28980 94623 62966 94029 89417 32026 67387 21098 88461 79787 80579 70439 2237 33005 12097 54566 79993 8709 84315 71961 30427 71102 53068 64440 91069 37835 78768 69298 89753 74749 31675 88761 16128 30652 40027 61119 7929 58346 90950 46...

output:

47
261
531
247
546
126
413
382
501
311
450
420
449
5545
909
231
327
2383
3923
407
165
469
1004
244
2983
367
266
89
69
111
262
135
296
103
390
394
28
190
51
34
1023
652
275
257
94
5991
776
377
460
3
297
1097
267
865
84
132
1899
4363
568
1035
378
182
372
210
973
326
325
1096
308
412
1422
377
188
249
3...

result:

ok 1000000 numbers

Test #76:

score: 17
Accepted
time: 573ms
memory: 67656kb

input:

100000 1000000
27336 37910 97070 44183 29995 49758 375 48516 91840 91049 29697 89681 32833 2308 86559 61177 42205 96692 91604 2444 91144 27682 4676 99797 22019 16247 9417 50225 31431 70808 46328 50017 63524 5278 18670 63198 15944 74354 67677 93050 12088 76013 79026 55614 12339 14182 46310 13428 9916...

output:

1911
209
168
2145
1026
1117
1044
1328
1907
2396
1030
4802
256
1292
959
498
77
1994
129
37
546
320
3427
106
966
73
177
58
2261
27
243
3637
1085
45
45
988
104
3657
251
4347
115
770
3347
1269
584
4478
2780
2149
35
416
1042
687
279
4
405
2917
66
29
1673
90
8080
44929
87
1788
1107
0
762
570
135
313
19
11...

result:

ok 1000000 numbers

Test #77:

score: 17
Accepted
time: 556ms
memory: 68364kb

input:

100000 1000000
68832 32373 8416 96939 39398 89861 29491 80771 77258 91216 42470 36368 41607 85762 23748 83036 89913 79306 47521 95952 29390 20501 22320 61997 44162 1438 68695 60447 44225 2645 58263 31482 15544 53525 58961 27875 52303 33973 73625 90950 47618 59073 53737 73936 31350 51029 30325 80075 ...

output:

8749
2770
20977
309
7773
4348
416
1240
367
15
6011
1206
373
2668
1110
1366
1497
260
884
3545
2411
551
2031
5352
1775
830
6526
5956
508
2278
333
612
2206
2064
331
177
687
61
3358
1727
50
174
2120
864
540
3105
8855
691
40
23010
81
5080
284
8147
71
423
618
257
192
4583
193
2371
552
1332
2591
7580
6272
...

result:

ok 1000000 numbers

Test #78:

score: 17
Accepted
time: 562ms
memory: 68272kb

input:

100000 1000000
52596 92870 23336 2940 51422 3326 1167 15935 53574 32223 81209 78304 83774 19456 84269 63599 20409 59292 92654 72663 84426 54904 4555 97549 67958 6560 59682 2957 1954 73007 52716 10774 13088 65980 84260 82038 63214 89012 7045 57303 83156 65553 70535 26354 30036 41508 47950 98012 17904...

output:

11013
70
1613
1
26
344
3485
3395
91
662
17335
474
2066
10053
6183
2078
645
5732
2232
3205
1451
1647
12830
243
666
313
1831
1031
10313
393
76
1839
12266
1
1994
5955
116
1361
137
11
1057
216
281
23
3
1960
2940
347
3681
894
270
11
17
1350
336
3552
11336
1166
76
141
668
70
248
374
1941
4884
7
39
223
174...

result:

ok 1000000 numbers

Test #79:

score: 17
Accepted
time: 538ms
memory: 68444kb

input:

100000 1000000
15420 36295 57572 93259 99933 50829 54093 49401 5332 28155 61095 6514 9327 99477 79061 28414 68820 15733 72024 19460 5065 33104 7113 14199 89800 27727 75921 28069 31768 92999 25500 29175 23886 67063 57533 15833 99593 44538 18029 18572 88196 20223 30186 83539 27104 20858 40712 47967 63...

output:

44200
6310
7528
445
1189
1219
754
93
9088
1756
343
6512
566
22
21
29
17137
5903
809
283
5324
265
2556
10
2235
0
3495
4072
207
328
1803
511
315
23601
426
4
4539
9994
3302
296
4256
50
248
1901
575
4095
316
18938
14
351
17694
1
110
32
20517
9371
0
1420
2783
24046
39
2
2183
1683
19003
1979
2
2585
2110
1...

result:

ok 1000000 numbers

Test #80:

score: 17
Accepted
time: 512ms
memory: 68380kb

input:

100000 1000000
23007 79987 89085 99883 96890 99740 10510 70065 80644 86465 83082 10861 54100 56151 78066 41733 95343 6465 84266 14586 46762 77397 87648 73739 94595 23429 24847 79180 61005 67082 45153 34209 20140 13723 95468 17581 72087 15113 7465 83662 41715 23460 70251 68712 96312 25166 77212 72078...

output:

6775
1
200
19613
2913
4
12483
4
14392
28468
7570
0
11
10889
10923
1645
62
9854
2366
31
402
287
10162
390
16
10532
36
26536
13
0
41324
1
33
9348
3
42
5
3285
620
708
3591
521
1554
67
4016
8228
16130
12520
5945
2878
3
1
7645
72
12417
18127
116
18836
1037
235
558
2981
2513
8388
2
8095
4588
9184
0
21102
...

result:

ok 1000000 numbers

Test #81:

score: 17
Accepted
time: 494ms
memory: 68420kb

input:

100000 1000000
6874 55215 44688 21029 96008 42093 94483 28006 67048 63875 9543 95388 34487 7920 84724 67671 20513 28031 87091 60617 7163 70679 85227 57608 99709 40202 20309 50381 59016 40420 17856 98797 29758 48068 64406 93303 31058 62263 39898 8334 24046 61116 8489 48505 64262 21361 19110 13339 393...

output:

199
1
6
6
132
39
6
0
2
0
571
66
384
39
18
1385
0
20
24324
1
10282
5
18
9
27
0
7447
2
209
0
0
60162
22
4887
1
5
1886
13
207
4856
7354
12257
836
7611
273
1766
225
1
7960
1
1339
5296
3889
5
1
26
13
502
129
3930
1
22692
369
5
3
994
0
8890
4907
18
6765
14490
1430
13744
1341
60
11523
3
790
288
60
31328
14...

result:

ok 1000000 numbers

Test #82:

score: 17
Accepted
time: 472ms
memory: 67288kb

input:

100000 1000000
17834 22054 72610 46642 21637 53082 15264 47998 87761 76459 24702 54577 9644 44178 58830 36410 10000 35585 19346 38067 17765 12195 54569 45885 53340 54087 40382 63714 97632 63376 34408 39500 46514 67792 76734 65909 72776 52002 31732 58756 74778 43101 58065 54366 5773 40826 53405 30037...

output:

1
10267
1793
24537
26158
1
8883
612
1521
12251
2464
0
4653
24
302
59
33728
38156
11030
11263
3
12
23287
51
118
11058
1
1
3
412
3310
7
3
21
12
1316
5
2345
4
1386
3
12
3
3388
144
2527
1205
5
26
0
0
7
90
1127
660
34
11
37
332
628
981
1383
146
11214
1982
2
4
7489
1157
5339
103
1
3974
304
0
1569
37
56560...

result:

ok 1000000 numbers

Test #83:

score: 17
Accepted
time: 472ms
memory: 65336kb

input:

100000 1000000
59129 31244 44964 75131 93021 51917 34849 16168 68826 58861 47237 79237 53040 95035 55624 78434 88324 77851 67656 7423 68800 53112 5815 50841 72358 75439 832 42411 55132 93762 13270 15672 76428 81253 91794 93129 2423 94555 25851 71221 39036 1237 53352 48995 7590 10978 141 41199 5320 2...

output:

10979
1236
8193
17068
2
307
106
8
4057
179
3080
333
107
83
1
5213
107
5682
161
4110
12
9084
695
11
0
5
6694
28698
1
8
2
11992
945
1595
2244
1262
6000
238
11
3
17
19
1
52
4634
5
7
2
1795
94
22
1
17836
11
487
4528
8
0
22921
1631
28605
32897
2
6
6
22511
832
1
1
302
3
0
4
1
645
1
767
146
19890
8
0
1692
...

result:

ok 1000000 numbers

Test #84:

score: 17
Accepted
time: 472ms
memory: 67572kb

input:

100000 1000000
31208 41388 48444 11248 50934 86740 72386 44148 67070 46997 4751 51745 54547 41171 17747 36588 27750 66759 72664 91402 61748 82397 39043 63144 63459 55640 42600 34626 45571 39473 53454 10882 17685 51272 35736 23354 98093 1742 60914 11323 23605 21237 80538 70719 23363 90612 40619 7723 ...

output:

1
3600
70
2587
134
22
12442
17
3
27802
6571
17
23837
8
2
11722
6818
12
5
142
8
11688
36235
5
2018
0
5314
5
22
1044
1
14
8330
53
387
29
0
485
0
2407
27996
8654
448
2594
9901
9533
30
27
121
48
3
2
25834
193
43
0
303
1
12
7412
680
589
48
23
4
28
10110
1
14840
23853
5
3299
1390
434
42
4935
16
887
0
25
6...

result:

ok 1000000 numbers

Test #85:

score: 17
Accepted
time: 470ms
memory: 67864kb

input:

100000 1000000
62227 89636 44712 93145 33932 88276 27763 84017 25800 72311 49226 51030 817 3102 54075 15902 75228 93345 86323 2506 11489 83523 42726 28765 39741 49200 14168 35458 54019 72751 34838 45980 66810 57521 94015 25363 90960 4794 70534 18030 51977 22939 49713 61227 22724 32841 87983 65650 50...

output:

652
1
43
3
22153
256
56
9
572
21
15
1
423
6
18702
1126
2339
1132
25114
3
7573
6
16
1236
26658
466
226
9
2741
1395
9
7
580
14
213
4
702
35
12
4
633
11850
189
491
1651
3
48
497
437
15
1680
1390
10062
21
109
250
3
89
3
1
12
2410
3
422
205
1371
199
806
637
3
1
1
8196
1521
28146
21
133
15076
20
162
2
4
2...

result:

ok 1000000 numbers

Test #86:

score: 17
Accepted
time: 452ms
memory: 67440kb

input:

100000 1000000
72858 73980 88791 8425 71525 63657 1356 59804 82996 16120 26166 25414 68209 55611 31495 87701 4850 67695 73380 71084 97531 5808 39850 36342 65918 25977 63697 14493 81146 12191 35948 83263 81285 13612 29801 80982 84536 99665 33889 34386 14432 75661 43374 44075 29060 55876 21467 17337 8...

output:

6248
97
25000
3124
781
3
3123
0
12
49286
1562
12462
195
0
1
0
1524
97
97
390
49670
12477
97
6
5204
12237
6223
5914
12
6
195
195
6249
12
1
6250
3125
390
1562
195
12
48
195
1
3108
24916
11378
195
195
390
6249
390
390
12500
24787
48
6
693
3081
781
3
195
1
12
195
3
781
6
40297
6250
24
6
48
195
6249
3
30...

result:

ok 1000000 numbers

Subtask #6:

score: 0
Skipped

Dependency #1:

0%