QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#600270#5002. Distance and Tree1025497292AC ✓76ms25200kbC++172.0kb2024-09-29 15:36:282024-09-29 15:36:30

Judging History

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

  • [2024-09-29 15:36:30]
  • 评测
  • 测评结果:AC
  • 用时:76ms
  • 内存:25200kb
  • [2024-09-29 15:36:28]
  • 提交

answer

#include<bits/stdc++.h>
#define endl '\n'
#define int long long
#define Mirai ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
typedef pair<int,int> pii;
const int N=1e5+10;
void solve()
{
    int n;cin>>n;
    set<int> st;
    vector<pii> res;
    vector<vector<int>> dep(n+1);
    vector<int> a(n+1);
    for(int i=0;i<n;i++)
    {
        int x;cin>>x;
        a[i]=x;
        dep[x].push_back(i);
    }
    if(dep[0].size()!=1)
    {
        cout<<-1<<endl;
        return ;
    }
    for(int i=0;i<3;i++)//root
    {
        st.insert(dep[0].back()+i*n);
    }
    for(auto u:dep[1])//1
    {
        res.push_back({dep[0].back()+1,u+1});
        for(int i=0;i<3;i++)
        {
            st.insert(u+i*n);
        }
    }

    // for(auto it:st)cout<<it<<" ";
    // cout<<endl;


    for(int depth=2;depth<=n-1;depth++)
    {
        // cout<<depth<<endl;
        for(auto u:dep[depth])
        {
            // cout<<u<<" ";
            u+=n;
            auto r=st.upper_bound(u);
            // cout<<u%n<<":";
            // cout<<*r%n<<" ";
            // cout<<a[(*r)%n]<<" ";
            if(a[(*r)%n]==depth-1)
            {
                res.push_back({(*r)%n+1,u-n+1});
            }
            else
            {
                r--;
                // cout<<a[(*r)%n]<<" ";
                if(a[(*r)%n]==depth-1)
                {
                    res.push_back({(*r)%n+1,u-n+1});
                }
                else 
                {
                    cout<<-1<<endl;
                    return ;
                }
            } 
            // cout<<endl;
        }
        for(auto u:dep[depth])
        {
            for(int j=0;j<3;j++)
            {
                st.insert(u+j*n);
            }
        }
    }
    for(auto it:res)cout<<it.first<<" "<<it.second<<endl;
}
signed main()
{
    Mirai;
    int T=1;
    // cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
0 1 2 1 3

output:

-1

result:

ok Accepted

Test #2:

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

input:

5
1 1 0 1 1

output:

3 1
3 2
3 4
3 5

result:

ok Accepted

Test #3:

score: 0
Accepted
time: 76ms
memory: 25132kb

input:

100000
96770 96764 96762 96761 96759 96755 96754 96753 96752 96751 96750 96748 96746 96745 96741 96740 96739 96736 96735 96734 96730 96728 96727 96726 96723 96718 96714 96712 96710 96709 96706 96705 96704 96703 96702 96698 96697 96696 96695 96693 96692 96690 96687 96684 96683 96682 96681 96679 96677...

output:

48445 48444
48444 48446
48446 48443
48443 48442
48442 48441
48441 48440
48440 48439
48439 48447
48447 48438
48438 48437
48437 48436
48436 48435
48435 48448
48448 48449
48449 48434
48434 48450
48450 48433
48433 48432
48432 48431
48431 48451
48451 48430
48430 48452
48452 48453
48453 48429
48429 48454
...

result:

ok Accepted

Test #4:

score: 0
Accepted
time: 68ms
memory: 25008kb

input:

100000
36370 36368 36365 36364 36362 36360 36356 36355 36354 36351 36349 36348 36336 36332 36331 36329 36327 36326 36325 36324 36321 36318 36317 36315 36314 36310 36308 36305 36304 36303 36299 36297 36295 36294 36291 36290 36289 36286 36284 36283 36280 36279 36276 36275 36273 36271 36269 36268 36267...

output:

18266 18265
18265 18264
18264 18263
18263 18262
18262 18261
18261 18260
18260 18259
18259 18258
18258 18257
18257 18256
18256 18255
18255 18267
18267 18268
18268 18269
18269 18270
18270 18254
18254 18271
18271 18253
18253 18272
18272 18252
18252 18251
18251 18273
18273 18250
18250 18249
18249 18274
...

result:

ok Accepted

Test #5:

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

input:

100000
62834 62837 62839 62841 62844 62845 62849 62850 62852 62853 62854 62855 62857 62859 62863 62866 62867 62871 62873 62875 62876 62877 62880 62882 62885 62887 62888 62889 62890 62892 62894 62897 62898 62899 62905 62909 62910 62913 62914 62915 62916 62917 62918 62919 62920 62921 62922 62923 62925...

output:

68600 68599
68599 68598
68598 68601
68601 68602
68602 68597
68597 68603
68603 68604
68604 68596
68596 68605
68605 68595
68595 68606
68606 68607
68607 68608
68608 68594
68594 68609
68609 68610
68610 68593
68593 68592
68592 68611
68611 68591
68591 68590
68590 68589
68589 68612
68612 68588
68588 68587
...

result:

ok Accepted

Test #6:

score: 0
Accepted
time: 62ms
memory: 25200kb

input:

100000
57363 57369 57371 57372 57373 57375 57376 57378 57380 57383 57385 57389 57390 57394 57395 57396 57399 57401 57402 57403 57406 57409 57410 57412 57422 57423 57425 57426 57429 57432 57433 57438 57439 57441 57444 57448 57449 57450 57455 57458 57462 57463 57468 57469 57472 57475 57476 57477 57478...

output:

71451 71452
71452 71453
71453 71450
71450 71449
71449 71448
71448 71447
71447 71454
71454 71455
71455 71446
71446 71456
71456 71445
71445 71457
71457 71444
71444 71443
71443 71458
71458 71442
71442 71441
71441 71459
71459 71440
71440 71460
71460 71439
71439 71461
71461 71462
71462 71438
71438 71463
...

result:

ok Accepted

Test #7:

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

input:

100000
55980 55983 55985 55987 55988 55991 55992 55993 55994 55995 55996 55997 55999 56005 56008 56009 56011 56014 56015 56017 56018 56028 56029 56033 56035 56037 56038 56040 56044 56050 56051 56055 56058 56062 56064 56070 56074 56076 56079 56082 56083 56085 56086 56087 56089 56091 56092 56095 56099...

output:

71913 71912
71912 71911
71911 71914
71914 71910
71910 71915
71915 71909
71909 71916
71916 71908
71908 71917
71917 71918
71918 71907
71907 71906
71906 71919
71919 71905
71905 71904
71904 71903
71903 71902
71902 71901
71901 71900
71900 71920
71920 71899
71899 71898
71898 71897
71897 71896
71896 71921
...

result:

ok Accepted

Test #8:

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

input:

1000
582 580 578 575 574 570 569 559 558 557 555 553 551 550 549 548 546 544 543 542 541 534 531 529 528 525 524 523 521 520 519 517 514 502 500 498 496 495 494 493 491 490 486 484 483 477 474 473 472 471 470 469 468 466 465 464 461 459 458 453 449 448 445 444 440 439 438 436 435 434 433 432 428 425...

output:

297 298
298 296
296 299
299 295
295 294
294 293
293 292
292 291
291 290
290 289
289 300
300 288
288 301
301 287
287 302
302 303
303 286
286 304
304 305
305 306
306 285
285 284
284 307
307 308
308 309
309 283
283 310
310 311
311 282
282 281
281 280
280 312
312 313
313 279
279 278
278 277
277 276
276 ...

result:

ok Accepted

Test #9:

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

input:

1000
921 922 927 928 931 932 933 935 936 940 941 942 947 948 949 950 952 956 957 961 965 969 970 971 972 973 977 979 980 984 985 986 988 989 990 992 994 999 998 997 996 995 993 991 987 983 982 981 978 976 975 974 968 967 966 964 963 962 960 959 958 955 954 953 951 946 945 944 943 939 938 937 934 930...

output:

542 543
543 541
541 544
544 540
540 545
545 539
539 546
546 547
547 538
538 537
537 536
536 535
535 548
548 549
549 550
550 551
551 534
534 552
552 533
533 553
553 554
554 555
555 532
532 531
531 556
556 557
557 530
530 529
529 528
528 558
558 559
559 527
527 560
560 526
526 561
561 562
562 563
563 ...

result:

ok Accepted

Test #10:

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

input:

1000
658 660 661 666 667 668 672 677 678 679 680 681 683 684 686 688 689 690 691 695 697 698 701 702 705 708 711 713 715 716 719 720 722 727 731 734 738 740 742 744 747 748 749 750 751 752 753 757 760 761 766 768 769 770 771 772 773 774 775 778 779 780 781 782 783 784 785 788 789 790 791 792 793 794...

output:

678 677
677 676
676 675
675 674
674 679
679 673
673 680
680 672
672 671
671 670
670 669
669 681
681 668
668 682
682 683
683 684
684 685
685 686
686 687
687 667
667 688
688 689
689 666
666 690
690 665
665 691
691 664
664 692
692 663
663 693
693 694
694 695
695 696
696 662
662 661
661 697
697 660
660 ...

result:

ok Accepted

Test #11:

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

input:

1000
221 222 225 226 229 230 231 232 235 236 237 238 240 242 243 244 245 246 248 250 253 254 255 256 263 266 269 271 272 274 275 276 277 279 280 282 284 285 286 287 290 295 296 299 301 302 304 305 307 310 312 313 314 315 317 319 320 324 325 329 334 337 339 344 345 346 348 351 352 355 357 361 362 363...

output:

898 899
899 897
897 896
896 895
895 900
900 894
894 893
893 892
892 891
891 890
890 901
901 889
889 888
888 902
902 903
903 904
904 887
887 886
886 885
885 905
905 884
884 906
906 907
907 883
883 908
908 882
882 881
881 880
880 879
879 909
909 910
910 878
878 877
877 876
876 875
875 874
874 873
873 ...

result:

ok Accepted

Test #12:

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

input:

1000
186 187 188 189 190 191 194 196 199 201 203 205 206 210 211 212 213 216 217 219 220 221 223 229 231 235 240 241 243 244 245 246 247 248 250 255 257 258 259 262 263 264 266 267 268 269 272 273 275 276 278 281 282 283 284 291 292 294 301 302 304 305 307 311 316 317 318 319 322 326 327 328 333 334...

output:

917 916
916 915
915 918
918 914
914 919
919 920
920 921
921 922
922 923
923 913
913 924
924 912
912 911
911 910
910 909
909 925
925 926
926 908
908 907
907 927
927 906
906 905
905 904
904 928
928 929
929 903
903 902
902 901
901 930
930 931
931 900
900 899
899 898
898 932
932 933
933 897
897 934
934 ...

result:

ok Accepted

Test #13:

score: 0
Accepted
time: 0ms
memory: 3524kb

input:

10
4 3 2 1 0 5 6 9 8 7

output:

5 4
4 3
3 2
2 1
1 6
6 7
7 10
10 9
9 8

result:

ok Accepted

Test #14:

score: 0
Accepted
time: 0ms
memory: 3524kb

input:

10
0 1 4 5 9 8 7 6 3 2

output:

1 2
2 10
10 9
9 3
3 4
4 8
8 7
7 6
6 5

result:

ok Accepted

Test #15:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

10
5 6 8 9 7 3 0 1 2 4

output:

7 8
8 9
9 6
6 10
10 1
1 2
2 5
5 3
3 4

result:

ok Accepted

Test #16:

score: 0
Accepted
time: 0ms
memory: 3788kb

input:

10
3 0 1 2 7 9 8 6 5 4

output:

2 3
3 4
4 1
1 10
10 9
9 8
8 5
5 7
7 6

result:

ok Accepted

Test #17:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

10
5 9 8 7 6 0 1 2 3 4

output:

6 7
7 8
8 9
9 10
10 1
1 5
5 4
4 3
3 2

result:

ok Accepted

Test #18:

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

input:

50000
22746 22745 22743 22742 22739 22735 22733 22732 22731 22729 22727 22724 22722 22720 22719 22717 22716 22714 22713 22708 22707 22706 22705 22703 22702 22700 22698 22693 22692 22689 22687 22685 22683 22682 22680 22679 22678 22676 22674 22671 22667 22665 22664 22661 22659 22658 22656 22650 22649 ...

output:

11425 11424
11424 11423
11423 11422
11422 11421
11421 11420
11420 11419
11419 11418
11418 11417
11417 11426
11426 11427
11427 11428
11428 11429
11429 11416
11416 11415
11415 11414
11414 11430
11430 11413
11413 11431
11431 11412
11412 11432
11432 11411
11411 11410
11410 11409
11409 11408
11408 11433
...

result:

ok Accepted

Test #19:

score: 0
Accepted
time: 39ms
memory: 14136kb

input:

50000
27526 27521 27520 27519 27517 27511 27506 27505 27504 27499 27497 27495 27492 27490 27489 27488 27486 27482 27481 27480 27478 27477 27476 27475 27474 27473 27468 27467 27466 27465 27463 27462 27461 27460 27455 27454 27452 27451 27449 27448 27447 27445 27444 27442 27441 27440 27439 27438 27436 ...

output:

13762 13763
13763 13764
13764 13761
13761 13760
13760 13759
13759 13758
13758 13757
13757 13765
13765 13766
13766 13756
13756 13755
13755 13767
13767 13768
13768 13769
13769 13754
13754 13753
13753 13752
13752 13770
13770 13771
13771 13772
13772 13773
13773 13774
13774 13775
13775 13776
13776 13751
...

result:

ok Accepted

Test #20:

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

input:

50000
18177 18178 18180 18181 18182 18183 18184 18185 18186 18188 18189 18190 18193 18194 18195 18196 18198 18200 18204 18206 18209 18212 18214 18215 18217 18218 18220 18221 18223 18226 18228 18230 18232 18234 18235 18236 18237 18238 18239 18240 18243 18244 18246 18248 18249 18250 18251 18254 18255 ...

output:

40891 40890
40890 40889
40889 40892
40892 40893
40893 40894
40894 40888
40888 40887
40887 40886
40886 40895
40895 40885
40885 40896
40896 40897
40897 40884
40884 40883
40883 40882
40882 40898
40898 40899
40899 40900
40900 40881
40881 40880
40880 40879
40879 40901
40901 40878
40878 40902
40902 40877
...

result:

ok Accepted

Test #21:

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

input:

50000
13195 13194 13193 13192 13191 13190 13186 13184 13181 13180 13179 13176 13172 13168 13166 13160 13159 13158 13156 13155 13154 13151 13150 13149 13148 13147 13145 13144 13142 13141 13138 13137 13135 13133 13132 13131 13130 13127 13126 13125 13124 13122 13121 13119 13113 13112 13111 13109 13106 ...

output:

6685 6684
6684 6686
6686 6683
6683 6687
6687 6682
6682 6688
6688 6681
6681 6689
6689 6690
6690 6691
6691 6692
6692 6693
6693 6694
6694 6680
6680 6695
6695 6696
6696 6679
6679 6678
6678 6697
6697 6677
6677 6676
6676 6698
6698 6699
6699 6700
6700 6701
6701 6702
6702 6675
6675 6674
6674 6703
6703 6704
...

result:

ok Accepted

Test #22:

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

input:

50000
1852 1856 1857 1858 1859 1860 1862 1868 1871 1873 1874 1875 1876 1877 1878 1879 1880 1882 1883 1885 1888 1891 1892 1896 1897 1898 1899 1901 1902 1904 1907 1910 1913 1914 1915 1916 1919 1922 1924 1933 1934 1939 1942 1943 1944 1945 1946 1947 1951 1952 1954 1958 1959 1960 1963 1967 1971 1972 1974...

output:

49095 49094
49094 49093
49093 49096
49096 49092
49092 49097
49097 49098
49098 49091
49091 49099
49099 49090
49090 49100
49100 49101
49101 49102
49102 49103
49103 49089
49089 49088
49088 49087
49087 49104
49104 49086
49086 49085
49085 49105
49105 49084
49084 49083
49083 49106
49106 49082
49082 49107
...

result:

ok Accepted

Test #23:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

10
0 1 2 3 4 1 3 4 2 3

output:

1 2
1 6
6 3
6 9
3 4
9 7
9 10
4 5
7 8

result:

ok Accepted

Test #24:

score: 0
Accepted
time: 14ms
memory: 8292kb

input:

100000
14879 87590 37413 82877 91816 99368 57722 18313 13232 60892 82794 83615 74864 40543 14870 85014 43195 10372 6873 49345 74272 13216 63600 69518 67189 49138 85317 50772 14868 77474 80767 29747 65064 18180 28977 56880 33900 86699 91545 47133 63943 90691 30748 55160 47586 61970 40174 90782 72342 ...

output:

-1

result:

ok Accepted

Test #25:

score: 0
Accepted
time: 11ms
memory: 8308kb

input:

100000
81178 95341 24040 3728 26335 48898 35932 98152 927 65240 82807 15496 29663 67304 7197 54578 66546 18582 8041 5923 5729 76555 53351 92767 61036 29539 68463 2428 7564 43887 41361 5095 39228 81753 8823 81916 30651 44755 96420 47930 26348 79228 63426 56011 62884 86975 26942 45782 5558 34983 51705...

output:

-1

result:

ok Accepted

Test #26:

score: 0
Accepted
time: 9ms
memory: 8312kb

input:

100000
53577 25315 53433 30671 6467 2872 84147 91912 85319 61542 47611 80695 26481 99184 41582 3433 77823 89796 77230 82767 28980 12731 72640 93192 69769 10999 26066 18889 52239 85327 83628 22168 26994 37062 52839 49814 39934 36986 41726 41605 14880 89338 22300 57713 4874 63882 61146 82697 70031 383...

output:

-1

result:

ok Accepted

Test #27:

score: 0
Accepted
time: 14ms
memory: 8296kb

input:

100000
81135 8663 9164 19316 86324 40203 5062 19568 82356 42929 5927 82216 98924 58933 66389 82692 72054 67580 12241 11633 81401 2763 38411 10157 74285 93803 99394 5099 38298 26499 11008 19433 51514 20172 38749 37838 76728 60163 73758 75436 3093 79685 57652 2017 38619 40394 84709 27025 7974 13303 38...

output:

-1

result:

ok Accepted

Test #28:

score: 0
Accepted
time: 10ms
memory: 8356kb

input:

100000
50905 98560 21701 12345 66048 48067 82660 29832 54525 71372 78765 94726 45795 66860 44975 87565 46302 72141 648 90792 39614 84964 12322 57149 78604 33000 56676 60927 43448 30819 1490 10706 29380 39543 39403 95428 87610 38415 25260 42135 9788 4026 53213 55583 87238 14540 59500 49892 86681 6014...

output:

-1

result:

ok Accepted

Test #29:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

1000
389 253 88 629 904 706 826 449 986 6 831 427 363 977 557 421 177 379 868 525 151 489 590 180 636 869 465 775 663 459 91 52 712 532 33 968 238 859 769 224 217 953 3 580 282 561 1 459 940 221 337 91 62 927 271 699 148 736 826 811 547 918 215 612 450 248 580 40 459 702 264 677 655 267 609 937 180 ...

output:

-1

result:

ok Accepted

Test #30:

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

input:

1000
790 91 483 213 442 184 2 936 155 65 927 281 302 281 221 399 823 2 158 68 766 977 962 992 371 127 856 921 808 540 943 950 983 426 164 426 610 518 714 117 935 641 399 589 274 972 989 449 327 147 518 445 476 480 437 199 959 645 120 768 186 415 70 521 842 586 299 804 105 13 274 392 7 673 982 281 99...

output:

-1

result:

ok Accepted

Test #31:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

1000
567 319 394 372 340 194 966 619 998 93 366 99 125 694 335 498 367 216 274 198 349 138 618 644 115 897 245 338 560 499 4 479 170 398 851 862 944 817 481 942 910 847 393 35 894 729 533 261 297 159 811 646 298 781 642 765 679 887 103 239 738 459 718 261 858 922 123 802 91 605 97 2 452 842 389 698 ...

output:

-1

result:

ok Accepted

Test #32:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

1000
692 429 923 196 573 950 350 696 594 53 802 151 459 735 550 873 632 715 78 602 573 823 793 127 712 311 896 956 82 692 872 775 121 795 323 46 746 673 94 692 79 248 196 890 336 746 115 320 813 194 923 386 17 68 866 729 731 762 37 166 806 909 293 279 705 616 678 803 289 772 495 720 373 691 610 61 7...

output:

-1

result:

ok Accepted

Test #33:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

1000
202 510 838 645 383 283 551 693 689 882 473 723 45 573 294 598 433 569 27 681 676 756 407 105 21 528 844 963 876 40 619 430 902 457 427 285 92 978 330 781 860 803 857 905 377 151 855 162 721 882 844 749 638 251 206 11 131 50 974 359 442 945 789 344 754 216 981 847 546 312 980 406 115 837 663 84...

output:

-1

result:

ok Accepted

Test #34:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

10
5 6 6 7 4 1 5 8 8 6

output:

-1

result:

ok Accepted

Test #35:

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

input:

10
6 0 1 1 2 8 1 0 5 3

output:

-1

result:

ok Accepted

Test #36:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

10
2 1 5 4 0 3 9 7 6 9

output:

-1

result:

ok Accepted

Test #37:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

10
9 8 7 8 7 5 4 5 9 6

output:

-1

result:

ok Accepted

Test #38:

score: 0
Accepted
time: 0ms
memory: 3472kb

input:

10
0 5 1 5 5 1 1 5 8 9

output:

-1

result:

ok Accepted

Test #39:

score: 0
Accepted
time: 6ms
memory: 5660kb

input:

50000
33913 532 38127 33353 3578 15234 43983 32672 22946 37844 32249 49533 3729 39801 21328 44522 11143 32850 33043 28846 32287 2258 16388 12556 37216 30241 34962 44478 32584 23184 21929 16498 23717 26408 16203 43647 41643 26538 26320 30941 30734 8569 30475 34463 14722 1803 45338 25865 1006 44733 21...

output:

-1

result:

ok Accepted

Test #40:

score: 0
Accepted
time: 3ms
memory: 5716kb

input:

50000
20498 38005 17560 14794 2319 19653 40349 34217 39094 23056 8668 43724 31914 17162 13977 39487 16082 20008 21394 39176 12096 6435 36270 30301 39025 36734 478 46842 122 13134 40439 20620 17491 8000 35415 19811 44005 42116 4028 49451 31524 12696 9528 29790 46210 23505 19278 12292 43514 7024 17820...

output:

-1

result:

ok Accepted

Test #41:

score: 0
Accepted
time: 3ms
memory: 5844kb

input:

50000
2078 12656 6446 27911 15092 29319 4809 10939 5717 22669 33900 42772 32276 18932 15047 44291 13239 29478 34243 36626 3998 43551 49800 16657 47172 13891 33427 15793 49884 25121 34792 18314 37777 7590 46225 19222 36910 17386 46513 42627 6408 46765 35399 5036 32049 16799 49328 45288 12629 49923 31...

output:

-1

result:

ok Accepted

Test #42:

score: 0
Accepted
time: 7ms
memory: 5716kb

input:

50000
26680 46058 18928 34937 26245 22060 3670 31236 44839 1362 10522 14491 39637 8281 7578 11167 22174 16412 5931 14446 4412 719 328 26397 11807 35659 34628 26146 20707 22121 20944 13739 34532 39872 48676 10777 28285 18699 8365 39476 36413 35239 20319 42402 43521 44250 3569 32047 10662 25852 12845 ...

output:

-1

result:

ok Accepted

Test #43:

score: 0
Accepted
time: 6ms
memory: 5680kb

input:

50000
37398 9325 44810 27451 9682 44314 36630 30210 20053 36304 48964 9937 12999 618 49834 44954 16297 33049 15847 35838 19363 38021 28378 47262 45179 12562 3229 41054 3119 19652 18101 40518 28977 29264 34321 5011 23578 20951 35222 9983 7256 538 19920 20255 1157 36106 31561 33806 19155 47408 35996 4...

output:

-1

result:

ok Accepted

Test #44:

score: 0
Accepted
time: 60ms
memory: 22792kb

input:

100000
0 2 1 1 2 1 2 1 2 1 1 1 1 1 3 3 2 1 2 1 3 2 3 1 1 1 1 1 2 2 1 1 2 1 2 1 2 1 1 2 1 1 1 2 1 1 1 1 2 3 1 1 2 1 2 2 2 1 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 2 2 1 2 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 2 1 2 2 1 2 1 1 2 1 2 1 1 2 1 1 1 1 1 1 2 1 3 3 2 3 1 1 1 1 1 2 1 2 2 1 2 1 1 1 1 1 2 1 2 1 1 1 1 1 1 1 1 2 1...

output:

1 3
1 4
1 6
1 8
1 10
1 11
1 12
1 13
1 14
1 18
1 20
1 24
1 25
1 26
1 27
1 28
1 31
1 32
1 34
1 36
1 38
1 39
1 41
1 42
1 43
1 45
1 46
1 47
1 48
1 51
1 52
1 54
1 58
1 59
1 60
1 61
1 62
1 63
1 64
1 65
1 66
1 67
1 69
1 70
1 72
1 73
1 76
1 78
1 79
1 82
1 83
1 84
1 85
1 86
1 87
1 88
1 89
1 90
1 91
1 92
1 94...

result:

ok Accepted

Test #45:

score: 0
Accepted
time: 60ms
memory: 22660kb

input:

100000
0 2 2 1 1 1 3 2 1 1 3 2 3 1 1 4 3 2 1 1 1 2 2 2 2 2 1 1 2 3 1 2 1 1 1 2 3 1 4 3 2 1 1 1 2 1 2 1 2 1 1 1 2 1 1 1 2 2 2 2 1 1 1 2 1 2 1 1 2 2 1 2 2 1 2 1 2 1 2 2 1 2 1 2 2 2 2 1 1 1 2 4 3 1 1 2 1 1 2 2 1 1 3 3 2 2 3 1 1 1 1 2 1 1 2 1 2 1 1 2 1 2 2 3 1 2 1 2 1 3 2 2 1 2 1 1 2 1 1 4 3 2 3 3 1 2 2...

output:

1 4
1 5
1 6
1 9
1 10
1 14
1 15
1 19
1 20
1 21
1 27
1 28
1 31
1 33
1 34
1 35
1 38
1 42
1 43
1 44
1 46
1 48
1 50
1 51
1 52
1 54
1 55
1 56
1 61
1 62
1 63
1 65
1 67
1 68
1 71
1 74
1 76
1 78
1 81
1 83
1 88
1 89
1 90
1 94
1 95
1 97
1 98
1 101
1 102
1 108
1 109
1 110
1 111
1 113
1 114
1 116
1 118
1 119
1 1...

result:

ok Accepted

Test #46:

score: 0
Accepted
time: 62ms
memory: 22636kb

input:

100000
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 56
1 57
1 58
1 59
1 60
1 61
1 62
1 63
1 64
1 6...

result:

ok Accepted

Test #47:

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

input:

100000
0 2 1 2 2 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 2 1 1 2 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 2 1 1 2 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 1 1 2 1 1 2 1 1...

output:

1 3
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 18
1 19
1 20
1 21
1 22
1 24
1 25
1 27
1 28
1 29
1 30
1 32
1 33
1 34
1 35
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 57
1 58
1 59
1 60
1 62
1 63
1 64
1 65
1 67
1 68
1 69
1 70
1 71
1 73
1 74
1 76
...

result:

ok Accepted

Test #48:

score: 0
Accepted
time: 56ms
memory: 22732kb

input:

100000
0 2 1 2 2 2 3 2 2 1 2 2 2 2 2 1 2 2 1 2 2 1 1 2 1 3 2 3 2 1 2 3 1 3 2 3 1 2 2 2 2 1 3 2 3 1 3 3 3 4 2 3 1 1 1 2 2 2 2 2 2 2 2 1 4 5 3 4 3 5 4 5 3 2 4 3 4 1 2 3 2 2 2 2 3 1 1 2 2 2 2 2 2 2 1 2 4 3 2 3 2 2 2 3 3 2 2 3 2 2 3 2 3 2 3 2 2 2 1 1 3 2 1 2 3 4 1 2 2 2 2 2 2 2 1 2 1 2 2 4 3 2 2 2 2 2 2...

output:

1 3
1 10
1 16
1 19
1 22
1 23
1 25
1 30
1 33
1 37
1 42
1 46
1 53
1 54
1 55
1 64
1 78
1 86
1 87
1 95
1 119
1 120
1 123
1 127
1 135
1 137
1 149
1 150
1 153
1 159
1 164
1 168
1 177
1 183
1 187
1 197
1 200
1 208
1 210
1 214
1 215
1 225
1 247
1 251
1 256
1 260
1 280
1 284
1 285
1 286
1 300
1 315
1 325
1 3...

result:

ok Accepted

Test #49:

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

input:

1000
0 3 2 1 1 1 1 2 1 3 2 2 3 1 1 1 1 2 2 3 3 1 2 2 2 1 1 2 1 2 3 2 1 1 1 1 1 1 1 2 1 1 2 1 1 3 2 3 2 1 1 1 1 1 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 2 1 1 1 1 1 1 3 2 1 2 1 1 1 1 1 1 2 1 2 1 1 1 1 1 1 2 3 2 1 1 2 2 2 2 1 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 2 1 1 2 1 1...

output:

1 4
1 5
1 6
1 7
1 9
1 14
1 15
1 16
1 17
1 22
1 26
1 27
1 29
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 41
1 42
1 44
1 45
1 50
1 51
1 52
1 53
1 54
1 55
1 57
1 59
1 60
1 61
1 62
1 63
1 64
1 65
1 66
1 67
1 68
1 69
1 70
1 71
1 72
1 73
1 74
1 75
1 76
1 78
1 79
1 80
1 83
1 84
1 85
1 86
1 87
1 88
1 91
1 93
1 94
...

result:

ok Accepted

Test #50:

score: 0
Accepted
time: 0ms
memory: 4028kb

input:

1000
0 2 1 2 1 1 1 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1 3
1 5
1 6
1 7
1 8
1 10
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 52
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1 62
1 63
1 64
1 65
1 66
1 67
1 68
1 69
...

result:

ok Accepted

Test #51:

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

input:

1000
0 1 1 2 1 1 1 2 1 1 2 1 1 1 2 1 1 1 1 2 1 2 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 2 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 2 1 1 1 2 1 1 1 1 2 1 1 1 1 1 2 1 1 1 1 3 2 1 1 1 1 2 1 1 2 2 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 1 1 1 1 2 2 1 2 1 2 1 2 1 1 2 1 1 1 1 2 1 1 2 2...

output:

1 2
1 3
1 5
1 6
1 7
1 9
1 10
1 12
1 13
1 14
1 16
1 17
1 18
1 19
1 21
1 23
1 24
1 25
1 27
1 28
1 29
1 30
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 50
1 52
1 53
1 54
1 55
1 57
1 58
1 59
1 60
1 61
1 62
1 64
1 65
1 67
1 68
1 69
1 70
1 71
1 73
1 74
1 75
1 77
1 78
1...

result:

ok Accepted

Test #52:

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

input:

1000
0 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 22
1 23
1 24
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 43
1 45
1 46
1 48
1 49
1 50
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1 62
1 63
1 64
1 65
1 66
1 67
1 69
1 70
1 7...

result:

ok Accepted

Test #53:

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

input:

1000
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 3 1 1 1 2 1 1 1 2 1 1 2 1 1 2 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 2 1 2 1 2 1 1 1 1 1 1 1 2 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 2 1 1 2 1 1 1...

output:

1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 34
1 35
1 36
1 38
1 39
1 40
1 42
1 43
1 45
1 46
1 48
1 49
1 50
1 51
1 52
1 53
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1 62
1 63
1 64
1 65
1 67
1 68
1 69
1 70
1 71
1 7...

result:

ok Accepted

Test #54:

score: 0
Accepted
time: 0ms
memory: 3452kb

input:

10
0 1 2 1 2 2 1 1 1 1

output:

1 2
1 4
1 7
1 8
1 9
1 10
4 3
7 5
7 6

result:

ok Accepted

Test #55:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

10
0 1 1 1 1 2 3 2 2 2

output:

1 2
1 3
1 4
1 5
5 6
5 8
5 9
5 10
8 7

result:

ok Accepted

Test #56:

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

input:

10
0 1 1 1 1 1 1 1 1 1

output:

1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10

result:

ok Accepted

Test #57:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

10
0 2 1 2 2 2 1 1 1 2

output:

1 3
1 7
1 8
1 9
3 2
7 4
7 5
7 6
9 10

result:

ok Accepted

Test #58:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

10
0 1 1 1 1 1 1 1 1 1

output:

1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10

result:

ok Accepted

Test #59:

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

input:

50000
0 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 2 1 1 1 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 1 2 1 1 1 1 1 1 2 2 1 1 1 1 1 1 2 1 1 1 1 1 1 2 3 1 1 1 2 1 1 2 1 1 2 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 ...

output:

1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 16
1 17
1 18
1 19
1 21
1 23
1 24
1 25
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 43
1 44
1 45
1 46
1 47
1 48
1 50
1 51
1 52
1 53
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1 62
1 63
1 65
1 66
1 67
1 68
1 70
1 71
1 73
1 74
1 75
1 76
1 7...

result:

ok Accepted

Test #60:

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

input:

50000
0 1 1 2 1 2 1 1 2 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 2 1 1 2 1 2 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 2 1 1 1 1 1 1 2 1 1 1 1 1 2 ...

output:

1 2
1 3
1 5
1 7
1 8
1 10
1 11
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 47
1 48
1 49
1 51
1 52
1 53
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1 63
1 64
1 65
1 66
1 67
1 68
1 69
1 70
1 72
...

result:

ok Accepted

Test #61:

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

input:

50000
0 1 1 2 1 2 1 1 1 2 1 1 2 1 1 2 1 2 2 3 2 2 1 2 1 2 1 2 1 2 1 2 1 1 2 1 1 2 1 2 1 2 1 2 1 1 1 1 1 2 1 1 2 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 1 3 2 2 1 1 1 1 1 1 2 2 1 1 1 2 2 2 2 1 1 1 2 1 2 1 1 1 1 1 1 2 1 2 1 1 2 2 1 1 2 1 1 1 1 1 2 1 1 2 3 3 1 1 3 2 2 2 1 1 2 1 3 2 3 3 1 1 1 1 1 2 1 3 2 2 1 2 ...

output:

1 2
1 3
1 5
1 7
1 8
1 9
1 11
1 12
1 14
1 15
1 17
1 23
1 25
1 27
1 29
1 31
1 33
1 34
1 36
1 37
1 39
1 41
1 43
1 45
1 46
1 47
1 48
1 49
1 51
1 52
1 54
1 55
1 56
1 57
1 59
1 60
1 62
1 63
1 64
1 65
1 66
1 67
1 68
1 69
1 70
1 74
1 75
1 76
1 77
1 78
1 79
1 82
1 83
1 84
1 89
1 90
1 91
1 93
1 95
1 96
1 97
1...

result:

ok Accepted

Test #62:

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

input:

50000
0 1 3 4 2 1 2 3 4 3 2 3 1 1 1 1 2 2 1 3 2 2 1 2 2 1 2 2 1 2 2 2 2 1 2 2 1 1 2 1 1 1 1 2 2 2 2 2 1 2 1 3 2 2 2 1 1 2 1 2 2 2 2 2 1 1 2 2 2 1 1 1 3 2 2 2 2 2 2 2 2 2 3 1 2 2 2 2 2 2 2 1 1 1 1 2 2 1 2 2 1 2 3 4 1 2 2 1 2 1 1 1 3 2 3 1 1 2 2 1 1 3 2 1 1 1 4 4 4 5 5 3 2 1 2 1 1 2 1 2 1 2 3 2 2 2 1 ...

output:

1 2
1 6
1 13
1 14
1 15
1 16
1 19
1 23
1 26
1 29
1 34
1 37
1 38
1 40
1 41
1 42
1 43
1 49
1 51
1 56
1 57
1 59
1 65
1 66
1 70
1 71
1 72
1 84
1 92
1 93
1 94
1 95
1 98
1 101
1 105
1 108
1 110
1 111
1 112
1 116
1 117
1 120
1 121
1 124
1 125
1 126
1 134
1 136
1 137
1 139
1 141
1 147
1 149
1 152
1 157
1 158...

result:

ok Accepted

Test #63:

score: 0
Accepted
time: 24ms
memory: 12840kb

input:

50000
0 1 2 1 3 3 3 2 3 2 1 2 1 2 1 2 3 3 2 3 2 3 2 1 2 3 1 2 4 3 1 2 1 2 2 2 1 1 2 1 3 4 2 2 2 3 2 3 1 2 2 2 2 2 2 2 2 2 3 2 2 2 2 3 1 2 2 3 2 4 3 2 3 3 2 3 2 2 3 3 2 4 3 2 1 2 1 2 1 2 1 2 2 3 2 3 2 2 2 3 3 2 2 2 3 2 2 3 2 2 2 3 1 3 2 1 2 2 2 2 2 2 2 2 1 3 2 3 2 2 3 2 1 3 5 4 3 4 4 3 4 2 2 3 3 3 1 ...

output:

1 2
1 4
1 11
1 13
1 15
1 24
1 27
1 31
1 33
1 37
1 38
1 40
1 49
1 65
1 85
1 87
1 89
1 91
1 113
1 116
1 125
1 133
1 147
1 153
1 154
1 155
1 157
1 158
1 168
1 176
1 190
1 201
1 204
1 215
1 227
1 238
1 258
1 287
1 297
1 318
1 320
1 355
1 361
1 362
1 366
1 378
1 381
1 396
1 413
1 414
1 423
1 427
1 428
1 ...

result:

ok Accepted