QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#709962#6521. Swapping OperationhhoppitreeWA 417ms6064kbC++172.2kb2024-11-04 17:40:032024-11-04 17:40:03

Judging History

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

  • [2024-11-04 17:40:03]
  • 评测
  • 测评结果:WA
  • 用时:417ms
  • 内存:6064kb
  • [2024-11-04 17:40:03]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;

int n, a[N], pre[N], nxt[N], res;

void brute() {
    for (int i = 1; i <= n; ++i) {
        pre[i] = (i == 1 ? a[i] : a[i] & pre[i - 1]);
    }
    for (int i = n; i >= 1; --i) {
        nxt[i] = (i == n ? a[i] : a[i] & nxt[i + 1]);
    }
    for (int i = 1; i < n; ++i) {
        res = max(res, pre[i] + nxt[i + 1]);
    }
}

int f[N], g[N];
map< pair<int, int>, int> M;

int calcMax(int x) {
    int res = 0;
    for (int i = 1; i <= n; ++i) res = max(res, a[i] & x);
    return res;
}

void calc(int x) {
    if (x == n) return;
    int val = (1 << 30) - 1;
    for (int i = 1; i < x; ++i) val &= a[i];
    f[x] = val;
    for (int i = x + 1; i < n; ++i) {
        f[i] = f[i - 1] & a[i];
    }
    g[n + 1] = a[x];
    for (int i = n; i >= x; --i) {
        g[i] = g[i + 1] & a[i];
    }
    if (n <= 2000) {
        for (int j = x + 1; j <= n; ++j) {
            for (int k = x; k < j; ++k) {
                res = max(res, (f[k] & a[j]) + g[k + 1]);
            }
        }
    } else {
        for (int j = 1; j < n; ++j) {
            M[{f[j], g[j + 1]}] = 1;
        }
    }
}

void solve(vector<int> pre) {
    for (auto x : pre) calc(x);
}

signed main() {
    int T; scanf("%d", &T);
    while (T--) {
        scanf("%d", &n);
        for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
        a[0] = a[n + 1] = 0;
        res = 0, brute();
        vector<int> Pre, Nxt;
        for (int i = 1; i <= n; ++i) {
            if (pre[i] != pre[i - 1]) Pre.push_back(i);
            if (nxt[i] != nxt[i + 1]) Nxt.push_back(i);
        }
        M.clear();
        solve(Pre);
        reverse(a + 1, a + n + 1);
        for (auto &x : Nxt) x = n - x + 1;
        solve(Nxt);
        for (auto &x : Nxt) x = n - x + 1;
        reverse(a + 1, a + n + 1);
        for (auto [x, y] : M) {
            res = max(res, calcMax(x.first) + x.second);
        }
        for (auto x : Pre) {
            for (auto y : Nxt) {
                swap(a[x], a[y]), brute(), swap(a[x], a[y]);
            }
        }
        printf("%d\n", res);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 4120kb

input:

3
6
6 5 4 3 5 6
6
1 2 1 1 2 2
5
1 1 2 2 2

output:

7
3
3

result:

ok 3 number(s): "7 3 3"

Test #2:

score: 0
Accepted
time: 55ms
memory: 3768kb

input:

1000
100
803046221 177233942 164782937 53823867 383853667 250036100 888743479 576687945 737272231 801579441 647643785 393059353 401516062 663466861 308544510 825328494 162739603 501761995 570908380 655227403 444493122 844535039 208303132 493226172 421479971 634680694 396627047 787471115 335787136 16...

output:

999397418
953601453
996676598
986700621
959469962
997532753
991939977
998064178
992514137
989100873
997784581
990111329
976588292
999515942
997721120
998122389
999751601
995753373
995915998
940455262
994686107
986433302
981799808
992366273
991914073
978772754
993464658
980800625
985148851
993204707
...

result:

ok 1000 numbers

Test #3:

score: 0
Accepted
time: 52ms
memory: 4112kb

input:

1000
100
868540859 536350094 243301178 399864672 63800499 60509883 662790489 933274863 712366832 250096549 353585859 849489613 287472674 378377984 318230727 227886897 734961837 146655379 415711604 114613730 147672354 398490255 401593832 198312435 896274101 473745940 345810320 745314936 192335687 317...

output:

993176411
990935453
989361310
998797029
997071496
997847030
993812394
978774674
986546369
979008739
973079854
992485632
996627688
991296275
985058500
982113648
986788726
989529759
991217219
976255336
999106271
983222240
998596661
989428133
995764679
968130163
996135026
975316802
984010492
999825964
...

result:

ok 1000 numbers

Test #4:

score: 0
Accepted
time: 417ms
memory: 3932kb

input:

100
1000
536870911 536870911 536870911 53060959 536870911 824976769 536870911 536870911 536870911 536870911 536870911 292812131 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 503316479 536870911 536870911 53...

output:

992267223
998203121
943491181
998903380
991177464
994506493
991568130
996548810
990887537
977900609
996604614
995782790
967198982
986736211
990460937
992025719
999311398
990411560
998302321
992464450
990685689
993256052
994112039
949448278
983078732
996318822
993360844
997651891
993329997
993539076
...

result:

ok 100 numbers

Test #5:

score: 0
Accepted
time: 416ms
memory: 3776kb

input:

100
1000
536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 5...

output:

989528581
993996713
987322111
997982929
998411959
998047555
999898583
983949131
997770426
986856306
986799747
998795930
999640185
984460916
996247390
997607144
996714502
959513743
999472672
988163119
992362297
986480589
999789548
987204597
998918966
999966811
995959839
957028075
977378449
995330581
...

result:

ok 100 numbers

Test #6:

score: 0
Accepted
time: 404ms
memory: 3916kb

input:

100
1000
536870911 536870911 536870911 536870911 536870911 873747431 536870911 536870911 536870911 536870911 336783235 536870911 536870911 536870911 312523694 536870911 4017189 536870911 536870911 536870911 536870911 290368219 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536...

output:

992519359
989582892
989345356
998114450
993532797
989582728
993903109
995936284
996498642
992674823
994002132
994542615
983215409
988921071
999812015
981484433
968086906
998292038
978463424
999965405
980176369
998066264
995426213
972214685
948402982
972799570
997541905
998460289
999426084
995312621
...

result:

ok 100 numbers

Test #7:

score: 0
Accepted
time: 410ms
memory: 3912kb

input:

100
1000
536870911 536870911 536870911 536870911 532704110 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 106395503 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 5...

output:

990153664
981943279
993427066
998331476
975536167
998348971
982632668
951082488
978270675
997843098
996280859
988633268
996123264
997099067
997282090
990623734
990869306
991019882
997017015
998700326
974472542
984414496
992295335
995838763
990083833
963265158
998577560
954058208
991843879
998783291
...

result:

ok 100 numbers

Test #8:

score: 0
Accepted
time: 38ms
memory: 3952kb

input:

10
10000
536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 5...

output:

990029081
996941040
996327033
997094193
990980188
986535974
995007098
992269180
986003383
990736573

result:

ok 10 numbers

Test #9:

score: 0
Accepted
time: 40ms
memory: 4312kb

input:

10
10000
536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 5...

output:

998160970
962252371
994002209
991351157
989772171
995168012
992749639
979618052
993648300
994703533

result:

ok 10 numbers

Test #10:

score: 0
Accepted
time: 41ms
memory: 4000kb

input:

10
10000
536870911 536870911 536870911 536870911 536870911 16495861 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 53...

output:

985813020
994294933
997857971
993640204
986032808
998285161
983501855
971946900
956658469
999420409

result:

ok 10 numbers

Test #11:

score: 0
Accepted
time: 36ms
memory: 3992kb

input:

10
10000
536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 313408423 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 313570023 536870911 536870911 536870911 5...

output:

982812296
997742114
981766884
999744972
997761413
998863157
985723058
993661054
978461035
988009489

result:

ok 10 numbers

Test #12:

score: 0
Accepted
time: 32ms
memory: 5764kb

input:

1
100000
536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 5...

output:

972405752

result:

ok 1 number(s): "972405752"

Test #13:

score: 0
Accepted
time: 45ms
memory: 5848kb

input:

1
100000
536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 5...

output:

998689648

result:

ok 1 number(s): "998689648"

Test #14:

score: 0
Accepted
time: 28ms
memory: 5760kb

input:

1
100000
536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 5...

output:

994388419

result:

ok 1 number(s): "994388419"

Test #15:

score: 0
Accepted
time: 34ms
memory: 5764kb

input:

1
100000
536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 5...

output:

989540923

result:

ok 1 number(s): "989540923"

Test #16:

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

input:

100
1000
65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 837325606 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 32767 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 126115569 1...

output:

982308028
996564253
996609583
997022165
999374550
985361560
999478520
993722720
991250154
979352632
986662229
941977900
994874484
987631482
986434267
992081760
983067730
981143075
960913139
968402815
977588561
994831317
974612625
988674180
999955804
997471683
999190084
998157218
989508864
990923047
...

result:

ok 100 numbers

Test #17:

score: 0
Accepted
time: 384ms
memory: 4104kb

input:

100
1000
616268620 1048575 1048575 1048575 452541743 1048575 1048575 1048575 1048575 1048575 1048575 606479664 1048575 1048575 1048575 1048575 1048575 1048575 1048575 1048575 1048575 1048575 1048575 1048575 363441026 1048575 1048575 1048575 1048575 1048575 1048575 1048575 1048063 1048575 1048575 104...

output:

996150731
984809627
995669944
982030168
991635773
993567985
997822209
991209301
981201290
998182500
997161166
981475211
992222302
996125404
991731823
996458082
992441428
986905918
980110015
994853843
994902592
987967626
997935529
993287385
978588380
994185418
992141092
998867415
993128068
998901163
...

result:

ok 100 numbers

Test #18:

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

input:

100
1000
65535 618316639 65535 65535 993627304 380378305 65535 65535 65535 945385481 65535 65535 65535 65535 65535 65535 79411578 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 914329319 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65527 65535 65535 65535 65535 65535 6553...

output:

993627304
997223787
995172986
967820232
922402818
997535890
993611366
992655911
990088233
974096338
991520197
994247557
986080004
988680068
999969094
989722792
993034847
997733224
981663826
999346544
988286385
985827812
998217951
996190322
997875057
990266756
961958261
999840457
997202565
965336151
...

result:

ok 100 numbers

Test #19:

score: 0
Accepted
time: 355ms
memory: 4144kb

input:

100
1000
65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 965746870 65535 65535 26067041 65535 65535 65535 65535 65535 65535 65407 815280236 65535 65535 65535 65535 65535 65535 141975591 31573753 65535 65535 65535 65535 65535 65535 65535 65535 65535 714044884 65535 65535 65535 65535 65535...

output:

994767992
999418764
999595232
989253454
995703749
995109821
995572054
998158226
998824617
993115590
995195933
998165626
988778437
999809543
999050273
989769941
988127888
997869761
973559942
976992249
983966156
994286226
985631965
999385566
999168590
991878403
990876708
997710130
998254097
975887194
...

result:

ok 100 numbers

Test #20:

score: 0
Accepted
time: 27ms
memory: 4020kb

input:

10
10000
65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 655...

output:

979181468
995314897
999891673
994759732
995272120
991865668
990726455
993478676
992528987
987220465

result:

ok 10 numbers

Test #21:

score: 0
Accepted
time: 30ms
memory: 4020kb

input:

10
10000
65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 655...

output:

959263243
991996367
995991242
997110748
948361300
977587814
974675025
993689915
983580122
999288163

result:

ok 10 numbers

Test #22:

score: 0
Accepted
time: 36ms
memory: 4324kb

input:

10
10000
33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 33554431 335...

output:

998080400
988696279
994030605
985117297
977015987
993716359
994170126
992382439
997862873
992083867

result:

ok 10 numbers

Test #23:

score: 0
Accepted
time: 38ms
memory: 4020kb

input:

10
10000
268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 2...

output:

993892148
982630093
970910815
997072305
976510027
997040055
985100681
996417543
995614901
995181841

result:

ok 10 numbers

Test #24:

score: 0
Accepted
time: 29ms
memory: 5828kb

input:

1
100000
268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 2...

output:

989497980

result:

ok 1 number(s): "989497980"

Test #25:

score: 0
Accepted
time: 49ms
memory: 6064kb

input:

1
100000
268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 2...

output:

985741038

result:

ok 1 number(s): "985741038"

Test #26:

score: 0
Accepted
time: 41ms
memory: 5740kb

input:

1
100000
268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 2...

output:

999945210

result:

ok 1 number(s): "999945210"

Test #27:

score: 0
Accepted
time: 43ms
memory: 5768kb

input:

1
100000
268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 268435455 2...

output:

967682724

result:

ok 1 number(s): "967682724"

Test #28:

score: 0
Accepted
time: 50ms
memory: 3892kb

input:

2000
50
368834445 502136717 402515949 99477359 402253581 368701357 368705535 401473453 268433183 132906943 401340269 502263599 236919675 367785869 100394767 367914765 535691229 234743695 367650621 401205103 367912781 99477439 401604399 502917103 502265805 133955453 134213439 267787059 240623442 2469...

output:

535691997
536779215
536788603
536800399
536870509
537921287
533715579
539191097
536862345
534249350
536609029
537003864
536608483
542065355
536858821
536861196
536458027
535600908
536330977
534768913
536599904
536867089
532365675
532676195
536862761
536871120
536870413
603994438
536764403
535801172
...

result:

ok 2000 numbers

Test #29:

score: 0
Accepted
time: 74ms
memory: 3824kb

input:

1000
100
451411959 245354934 187160566 179698623 443408375 530044406 168808886 514192311 446159358 266861502 461754806 445511606 168812542 527422455 192273335 191755766 246800310 175102966 172479991 189789623 529002999 253615615 235394046 260437430 510523839 442367479 523227582 183488951 256759295 1...

output:

536805033
528351395
536786329
536574720
536870257
536247452
536871110
536870633
536321365
536828411
536869357
536798876
536871119
536870881
545258170
536871200
536605236
536297682
536870975
536870746
536864478
536871223
536866140
536862655
536625848
536863055
536867016
531101670
536805981
536871339
...

result:

ok 1000 numbers

Test #30:

score: 0
Accepted
time: 115ms
memory: 3824kb

input:

500
200
536829271 266291657 266173219 266186525 266299729 266161947 536840700 268426213 534595858 534756189 268426551 266145187 534597608 536858075 268292067 266307891 534597062 266181411 536686582 266166263 266174402 534712202 536828359 266333523 534748053 536681893 268430226 536836402 536816926 26...

output:

536871031
536868039
536737074
536852005
536871868
536870487
536871462
536346743
536871171
536870310
536801220
536739481
536870371
536740627
535790110
536721988
536707382
536603910
534622352
536832175
536870568
536870849
536871098
536868885
536854633
536850904
536328262
536592284
536494021
536831862
...

result:

ok 500 numbers

Test #31:

score: 0
Accepted
time: 153ms
memory: 3828kb

input:

333
300
368343389 268235593 368493819 532052185 532571741 230449369 502645211 397797869 95899629 129297887 264100811 100583641 230483803 129780329 532081133 499020397 268398795 264107885 503311851 398321871 133558859 264005067 503177565 402081273 263551709 263585355 129286861 402475769 100586617 503...

output:

536758748
536838312
536866044
536830148
536869928
536862579
534754447
536804212
536871381
536864583
536871233
536865478
536869018
536870682
536871276
536866640
536860297
536869664
536871674
536871046
536869377
536870940
536654581
536853997
536583867
536871542
536506158
531349823
536837796
536805375
...

result:

ok 333 numbers

Test #32:

score: 0
Accepted
time: 226ms
memory: 3900kb

input:

200
500
401010685 233553663 460566493 125222909 402108415 493547261 58191583 65454077 201326333 259243773 326823933 402583295 359137277 24641279 501723135 100400861 400998109 200785917 91930335 301924093 494841821 333967327 233549823 266776575 91402239 90959837 427273949 402112509 124973023 33271805...

output:

536868504
536871413
536871379
536871580
536871708
536870667
536871828
536883423
536868817
536820006
536868354
536799171
536870229
536870942
536870851
536870803
536871412
536788417
536859035
536273246
536866629
536870393
536833609
536868991
536870483
536850177
536871101
536870123
536832361
536862300
...

result:

ok 200 numbers

Test #33:

score: 0
Accepted
time: 416ms
memory: 3848kb

input:

100
1000
525287141 527228903 485465839 482975461 485441533 257490943 233537511 517414637 535338997 474111999 491773935 501554919 524476135 205938423 474808055 475651815 476020471 216014589 511606781 233717479 257736679 249536495 525672173 482893823 247832575 492846821 484302565 259932151 500096759 5...

output:

536871444
536871589
536862577
536865506
536870914
536870926
536868164
536870983
536862641
536868427
536871617
536871093
536870925
536866739
536868589
536868799
536871693
536846321
536862835
536871533
536870162
536871259
536870861
536871214
536870377
536870767
536871527
536870937
536866521
536863012
...

result:

ok 100 numbers

Test #34:

score: 0
Accepted
time: 61ms
memory: 3940kb

input:

20
5000
263944879 196803183 188694078 465247167 468909886 528366462 187906862 528145343 196239358 465510143 528375743 263700335 456285119 456351551 196549294 456269807 263346926 268049150 264199086 268131054 188627567 188186367 259219070 188644926 468934463 259170111 528162367 197122798 469154543 45...

output:

536871389
536870653
536871303
536868922
536870905
536866430
536871219
536871097
536870974
536871520
536870847
536870927
536871182
536871038
536866623
536870529
671622779
536870975
536870912
536871287

result:

ok 20 numbers

Test #35:

score: 0
Accepted
time: 58ms
memory: 4328kb

input:

10
10000
494653375 117394142 368836603 426724250 74404859 293305242 16503710 234872735 82532059 217015995 493606591 377446303 49249178 108775099 267347707 309019294 468451227 369085339 141551322 133168858 242993114 209668767 402344894 267082491 141546138 493876923 300938202 251625183 58677242 587069...

output:

536871049
536870906
536870809
536871267
536870848
536871159
536871026
536870933
536870907
536870935

result:

ok 10 numbers

Test #36:

score: 0
Accepted
time: 82ms
memory: 5772kb

input:

1
100000
200987903 331019519 66907323 66825979 469687743 196717995 330948091 402228911 469755119 201186555 130014383 330934267 398190315 62703359 402189807 402246831 335329007 335449595 201254575 133740527 196775611 133889967 263831231 268275131 66761919 263892395 536457135 469337775 469403563 13400...

output:

536870953

result:

ok 1 number(s): "536870953"

Test #37:

score: -100
Wrong Answer
time: 7ms
memory: 3756kb

input:

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

output:

6
7
7
6
6
10
7
3
7
7
7
7
7
9
6
7
7
7
6
7
3
5
7
6
4
7
7
7
7
4
7
6
4
10
6
7
7
7
4
6
7
7
8
6
5
7
7
6
6
7
6
7
7
6
5
8
7
8
7
7
7
7
7
5
10
8
7
8
10
7
6
7
7
6
6
6
7
9
6
6
4
7
0
7
3
7
0
3
9
4
7
6
9
6
7
4
7
7
6
7
5
6
3
6
5
9
6
7
7
5
6
7
7
7
9
11
6
7
3
7
6
7
7
11
7
6
7
7
7
6
6
6
7
7
6
7
6
7
6
6
6
3
7
6
6
9
7
...

result:

wrong answer 87th numbers differ - expected: '7', found: '0'