QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#74729 | #5002. Distance and Tree | Smallbasic# | AC ✓ | 33ms | 34812kb | C++14 | 1.5kb | 2023-02-03 16:02:21 | 2023-02-03 16:02:25 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
inline int read() {
register int s = 0, f = 1; register char ch = getchar();
while (!isdigit(ch)) f = (ch == '-' ? -1 : 1), ch = getchar();
while (isdigit(ch)) s = (s * 10) + (ch & 15), ch = getchar();
return s * f;
}
int n, d[N], fr[N], to[N], top = 0, ord[N], dis[N];
vector<int> p[N];
inline void addedge(int from, int t) {
fr[++top] = from; to[top] = t;
}
inline int abs_(int a) {
return a < 0 ? -a : a;
}
#define VIT vector<int>::iterator
inline bool calc(int L, int l, int r, int d) {
if (l > r) return 1;
VIT it = lower_bound(p[d].begin(), p[d].end(), l);
if (*it > r) return 0;
int las = l;
for (; it != p[d].end() && *it <= r; ++it) {
addedge(L, *it);
if (!calc(*it, las, *it - 1, d + 1)) return 0;
las = *it + 1;
}
return calc(las - 1, las, r, d + 1);
}
int main() {
n = read();
for (int i = 1; i <= n; ++i) d[i] = read();
int rt = 0;
for (int i = 1; i <= n; ++i) {
if (!d[i]) {
if (rt) {
puts("-1");
return 0;
}
rt = i;
}
}
if (!rt) puts("-1");
else {
int cnt = 0;
for (int i = rt; i <= n; ++i) ord[++cnt] = i;
for (int i = 1; i < rt; ++i) ord[++cnt] = i;
for (int i = 1; i <= n; ++i) dis[i] = d[ord[i]];
for (int i = 1; i <= n; ++i)
p[dis[i]].push_back(i);
for (int i = 1; i <= n; ++i) p[i].push_back(n + 1);
if (calc(1, 2, n, 1))
for (int i = 1; i < n; ++i) printf("%d %d\n", ord[fr[i]], ord[to[i]]);
else puts("-1");
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 21900kb
input:
5 0 1 2 1 3
output:
-1
result:
ok Accepted
Test #2:
score: 0
Accepted
time: 0ms
memory: 22288kb
input:
5 1 1 0 1 1
output:
3 4 3 5 3 1 3 2
result:
ok Accepted
Test #3:
score: 0
Accepted
time: 26ms
memory: 33036kb
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: 23ms
memory: 34812kb
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: 31ms
memory: 33608kb
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: 33ms
memory: 33544kb
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: 18ms
memory: 33560kb
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: 21460kb
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: 2ms
memory: 21480kb
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: 8ms
memory: 21316kb
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: 3ms
memory: 21744kb
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: 8ms
memory: 22632kb
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: 1ms
memory: 22604kb
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: 1ms
memory: 22908kb
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: 1ms
memory: 22836kb
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: 7ms
memory: 21936kb
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: 2ms
memory: 21604kb
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: 7ms
memory: 27848kb
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: 5ms
memory: 27924kb
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: 16ms
memory: 27768kb
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: 4ms
memory: 27836kb
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: 17ms
memory: 29076kb
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: 4ms
memory: 21440kb
input:
10 0 1 2 3 4 1 3 4 2 3
output:
1 2 1 6 6 3 3 4 4 5 6 9 9 7 7 8 9 10
result:
ok Accepted
Test #24:
score: 0
Accepted
time: 9ms
memory: 22336kb
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: 23296kb
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: 1ms
memory: 19048kb
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: 3ms
memory: 17476kb
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: 1ms
memory: 18552kb
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: 6ms
memory: 17832kb
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: 5ms
memory: 22080kb
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: 1ms
memory: 18868kb
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: 1ms
memory: 20744kb
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: 2ms
memory: 20616kb
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: 17964kb
input:
10 5 6 6 7 4 1 5 8 8 6
output:
-1
result:
ok Accepted
Test #35:
score: 0
Accepted
time: 2ms
memory: 18136kb
input:
10 6 0 1 1 2 8 1 0 5 3
output:
-1
result:
ok Accepted
Test #36:
score: 0
Accepted
time: 5ms
memory: 20824kb
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: 17432kb
input:
10 9 8 7 8 7 5 4 5 9 6
output:
-1
result:
ok Accepted
Test #38:
score: 0
Accepted
time: 4ms
memory: 22108kb
input:
10 0 5 1 5 5 1 1 5 8 9
output:
-1
result:
ok Accepted
Test #39:
score: 0
Accepted
time: 9ms
memory: 24704kb
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: 9ms
memory: 18240kb
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: 1ms
memory: 18300kb
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: 9ms
memory: 24272kb
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: 7ms
memory: 24060kb
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: 15ms
memory: 26616kb
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 3 2 1 4 1 6 6 5 1 8 8 7 1 10 10 9 1 11 1 12 1 13 1 14 1 18 18 17 17 15 17 16 1 20 20 19 1 24 24 22 22 21 22 23 1 25 1 26 1 27 1 28 1 31 31 29 31 30 1 32 1 34 34 33 1 36 36 35 1 38 38 37 1 39 1 41 41 40 1 42 1 43 1 45 45 44 1 46 1 47 1 48 1 51 51 49 49 50 1 52 1 54 54 53 1 58 58 55 58 56 58 57 1 ...
result:
ok Accepted
Test #45:
score: 0
Accepted
time: 15ms
memory: 25404kb
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 4 2 4 3 1 5 1 6 1 9 9 8 8 7 1 10 1 14 14 12 12 11 12 13 1 15 1 19 19 18 18 17 17 16 1 20 1 21 1 27 27 22 27 23 27 24 27 25 27 26 1 28 1 31 31 29 29 30 1 33 33 32 1 34 1 35 1 38 38 36 36 37 1 42 42 41 41 40 40 39 1 43 1 44 1 46 46 45 1 48 48 47 1 50 50 49 1 51 1 52 1 54 54 53 1 55 1 56 1 61 61 57...
result:
ok Accepted
Test #46:
score: 0
Accepted
time: 16ms
memory: 26880kb
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 37 36 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 56 55 1 57 1 58 1 59 1 60 1 61 1 62 1...
result:
ok Accepted
Test #47:
score: 0
Accepted
time: 23ms
memory: 24836kb
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 3 2 1 6 6 4 6 5 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 18 18 17 1 19 1 20 1 21 1 22 1 24 24 23 1 25 1 27 27 26 1 28 1 29 1 30 1 32 32 31 1 33 1 34 1 35 1 37 37 36 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 46 46 45 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 57 57 56 1 58 1 59 1 60 1 62 6...
result:
ok Accepted
Test #48:
score: 0
Accepted
time: 16ms
memory: 26648kb
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 3 2 1 10 10 4 10 5 10 6 10 8 8 7 10 9 1 16 16 11 16 12 16 13 16 14 16 15 1 19 19 17 19 18 1 22 22 20 22 21 1 23 1 25 25 24 1 30 30 27 27 26 30 29 29 28 1 33 33 31 31 32 1 37 37 35 35 34 35 36 1 42 42 38 42 39 42 40 42 41 1 46 46 44 44 43 44 45 1 53 53 51 51 47 51 48 51 49 49 50 51 52 1 54 1 55 1...
result:
ok Accepted
Test #49:
score: 0
Accepted
time: 0ms
memory: 21140kb
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 4 3 3 2 1 5 1 6 1 7 1 9 9 8 1 14 14 11 11 10 14 12 12 13 1 15 1 16 1 17 1 22 22 18 22 19 19 20 19 21 1 26 26 23 26 24 26 25 1 27 1 29 29 28 1 33 33 30 33 32 32 31 1 34 1 35 1 36 1 37 1 38 1 39 1 41 41 40 1 42 1 44 44 43 1 45 1 50 50 47 47 46 50 49 49 48 1 51 1 52 1 53 1 54 1 55 1 57 57 56 1 59 5...
result:
ok Accepted
Test #50:
score: 0
Accepted
time: 1ms
memory: 23248kb
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 3 2 1 5 5 4 1 6 1 7 1 8 1 10 10 9 1 12 12 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 37 1 39 39 38 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 52 52 51 1 54 54 53 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 6...
result:
ok Accepted
Test #51:
score: 0
Accepted
time: 1ms
memory: 22504kb
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 5 4 1 6 1 7 1 9 9 8 1 10 1 12 12 11 1 13 1 14 1 16 16 15 1 17 1 18 1 19 1 21 21 20 1 23 23 22 1 24 1 25 1 27 27 26 1 28 1 29 1 30 1 32 32 31 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 41 41 40 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 50 50 49 1 52 52 51 1 53 1 54 1 55 1 57 57 56 1 58 1 59 1 60 1 6...
result:
ok Accepted
Test #52:
score: 0
Accepted
time: 1ms
memory: 22464kb
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 11 10 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 22 22 21 1 23 1 24 1 26 26 25 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 43 42 1 45 45 44 1 46 1 48 48 47 1 49 1 50 1 52 52 51 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1...
result:
ok Accepted
Test #53:
score: 0
Accepted
time: 5ms
memory: 22212kb
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 24 23 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 34 34 32 32 33 1 35 1 36 1 38 38 37 1 39 1 40 1 42 42 41 1 43 1 45 45 44 1 46 1 48 48 47 1 49 1 50 1 51 1 52 1 53 1 55 55 54 1 56 1 57 1 58 1 59 1 60 1 61 ...
result:
ok Accepted
Test #54:
score: 0
Accepted
time: 1ms
memory: 21440kb
input:
10 0 1 2 1 2 2 1 1 1 1
output:
1 2 1 4 4 3 1 7 7 5 7 6 1 8 1 9 1 10
result:
ok Accepted
Test #55:
score: 0
Accepted
time: 1ms
memory: 21532kb
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 8 7 5 9 5 10
result:
ok Accepted
Test #56:
score: 0
Accepted
time: 0ms
memory: 21672kb
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: 4ms
memory: 22328kb
input:
10 0 2 1 2 2 2 1 1 1 2
output:
1 3 3 2 1 7 7 4 7 5 7 6 1 8 1 9 9 10
result:
ok Accepted
Test #58:
score: 0
Accepted
time: 0ms
memory: 22044kb
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: 9ms
memory: 24352kb
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 16 15 1 17 1 18 1 19 1 21 21 20 1 23 23 22 1 24 1 25 1 31 31 26 31 27 31 28 31 29 31 30 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 43 43 42 1 44 1 45 1 46 1 47 1 48 1 50 50 49 1 51 1 52 1 53 1 55 55 54 1 56 1 57 1 58 1 59 1 60 1 ...
result:
ok Accepted
Test #60:
score: 0
Accepted
time: 9ms
memory: 24128kb
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 5 4 1 7 7 6 1 8 1 10 10 9 1 11 1 13 13 12 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 38 37 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 47 47 46 1 48 1 49 1 51 51 50 1 52 1 53 1 55 55 54 1 56 1 57 1 58 1 59 1 60 1 61 1 ...
result:
ok Accepted
Test #61:
score: 0
Accepted
time: 6ms
memory: 24152kb
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 5 4 1 7 7 6 1 8 1 9 1 11 11 10 1 12 1 14 14 13 1 15 1 17 17 16 1 23 23 18 23 19 23 21 21 20 23 22 1 25 25 24 1 27 27 26 1 29 29 28 1 31 31 30 1 33 33 32 1 34 1 36 36 35 1 37 1 39 39 38 1 41 41 40 1 43 43 42 1 45 45 44 1 46 1 47 1 48 1 49 1 51 51 50 1 52 1 54 54 53 1 55 1 56 1 57 1 59 59 ...
result:
ok Accepted
Test #62:
score: 0
Accepted
time: 15ms
memory: 23292kb
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 6 5 5 3 3 4 1 13 13 7 13 11 11 8 11 10 10 9 11 12 1 14 1 15 1 16 1 19 19 17 19 18 1 23 23 21 21 20 23 22 1 26 26 24 26 25 1 29 29 27 29 28 1 34 34 30 34 31 34 32 34 33 1 37 37 35 37 36 1 38 1 40 40 39 1 41 1 42 1 43 1 49 49 44 49 45 49 46 49 47 49 48 1 51 51 50 1 56 56 53 53 52 56 54 56 55 1...
result:
ok Accepted
Test #63:
score: 0
Accepted
time: 19ms
memory: 23208kb
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 4 3 1 11 11 8 8 5 8 6 8 7 11 10 10 9 1 13 13 12 1 15 15 14 1 24 24 16 24 19 19 17 19 18 24 21 21 20 24 23 23 22 1 27 27 25 25 26 1 31 31 28 28 30 30 29 1 33 33 32 1 37 37 34 37 35 37 36 1 38 1 40 40 39 1 49 49 43 43 41 41 42 49 44 49 45 49 47 47 46 47 48 1 65 65 50 65 51 65 52 65 53 65 54 65...
result:
ok Accepted