QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#826943 | #9772. Permutation Routing | ship2077 | AC ✓ | 83ms | 10240kb | C++23 | 2.6kb | 2024-12-22 17:29:24 | 2024-12-22 17:29:24 |
Judging History
你现在查看的是测评时间为 2024-12-22 17:29:24 的历史记录
- [2025-01-10 11:38:24]
- hack成功,自动添加数据
- (/hack/1438)
- [2024-12-22 17:29:24]
- 提交
answer
#include<bits/stdc++.h>
using namespace std;
constexpr int M=1005,inf=0x3f3f3f3f;
int n,p[M],P[M],dis[M][M];
vector<int>dp[M][2];
vector<pair<int,int>>adj[M];
vector<vector<int>>ans;
int read(){
int x=0;char ch=getchar();
while (!isdigit(ch)) ch=getchar();
while (isdigit(ch)) x=x*10+ch-48,ch=getchar();
return x;
}
bool check(){
for (int i=1;i<=n;i++)
if (i!=p[i]) return 1;
return 0;
}
void init(int x){ for (auto [y,z]:adj[x]) adj[y].erase(find(adj[y].begin(),adj[y].end(),make_pair(x,z))),init(y);}
void dfs(int x){
dp[x][0].resize(adj[x].size()+1);
dp[x][1].resize(adj[x].size()+1);
dp[x][0][0]=dp[x][1][0]=dis[p[x]][x]*dis[p[x]][x];
for (int i=0;i<adj[x].size();i++){
auto [y,z]=adj[x][i]; dfs(y);
dp[x][0][i+1]=dp[x][0][i]+min(dp[y][0].back(),dp[y][1].back());
dp[x][1][i+1]=min(dp[x][1][i]+min(dp[y][0].back(),dp[y][1].back()),
dp[x][0][i]+dp[y][0].back()+dis[y][p[x]]*dis[y][p[x]]+dis[x][p[y]]*dis[x][p[y]]-dis[p[x]][x]*dis[p[x]][x]-dis[p[y]][y]*dis[p[y]][y]);
}
}
void build(int x,int s){
for (int i=(int)adj[x].size()-1;~i;i--){
auto [y,z]=adj[x][i];
if (!s) build(y,dp[y][0].back()>=dp[y][1].back());
else if (dp[x][1][i]+min(dp[y][0].back(),dp[y][1].back())>=
dp[x][0][i]+dp[y][0].back()+dis[y][p[x]]*dis[y][p[x]]+dis[x][p[y]]*dis[x][p[y]]-dis[p[x]][x]*dis[p[x]][x]-dis[p[y]][y]*dis[p[y]][y])
build(y,0),swap(P[x],P[y]),ans.back().emplace_back(z),s=0;
else build(y,dp[y][0].back()>=dp[y][1].back());
}
}
void solve(){ n=read();
for (int i=1;i<=n;i++) p[i]=read();
for (int i=1;i<=n;i++) adj[i].clear();
for (int i=1;i<n;i++){
int x=read(),y=read();
adj[x].emplace_back(y,i);
adj[y].emplace_back(x,i);
} ans.clear();
for (int i=1;i<=n;i++){
for (int j=1;j<=n;j++) dis[i][j]=-1;
queue<int>q;q.push(i);dis[i][i]=0;
while (!q.empty()){
int x=q.front();q.pop();
for (auto [y,z]:adj[x])
if (dis[i][y]==-1) dis[i][y]=dis[i][x]+1,q.push(y);
}
} init(1);
while (check()){
dfs(1);ans.emplace_back();
for (int i=1;i<=n;i++) P[i]=p[i];
build(1,dp[1][0][adj[1].size()]>=dp[1][1][adj[1].size()]);
for (int i=1;i<=n;i++) p[i]=P[i];
}
printf("%d\n",(int)ans.size());
for (auto tmp:ans){
printf("%d ",(int)tmp.size());
for (auto x:tmp) printf("%d ",x);puts("");
}
}
int main(){int T=read();while (T--) solve();return 0;}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3744kb
input:
1 5 1 4 2 5 3 1 2 2 3 2 4 1 5
output:
3 2 4 3 1 1 2 4 2
result:
ok ok, up to 3 steps were used
Test #2:
score: 0
Accepted
time: 13ms
memory: 3832kb
input:
10000 5 2 3 1 5 4 1 5 3 2 1 2 1 4 5 1 2 3 4 5 2 3 3 4 2 1 4 5 5 4 2 5 1 3 3 5 2 3 4 1 3 1 5 1 3 4 2 5 5 3 2 1 1 3 2 4 5 1 2 3 4 5 2 1 3 5 2 3 5 4 5 1 2 3 4 5 4 5 3 4 4 2 4 1 5 5 2 1 4 3 2 1 5 1 3 1 1 4 5 4 1 2 5 3 3 1 5 1 1 2 1 4 5 5 3 4 2 1 3 1 3 5 4 3 3 2 5 3 4 1 2 5 3 2 3 5 1 5 3 4 5 3 4 1 2 5 2 ...
output:
4 2 4 2 1 1 1 4 1 3 0 1 2 1 3 3 1 3 1 2 2 3 4 0 0 2 1 2 1 3 4 1 4 1 2 1 1 1 3 5 1 3 1 4 1 1 1 2 1 1 5 1 3 1 2 2 4 3 1 1 1 4 3 1 2 2 4 1 1 2 3 1 1 1 4 1 2 0 5 2 3 4 2 1 2 2 3 4 2 1 2 2 3 4 4 2 3 2 1 1 2 3 2 1 1 1 2 2 1 0 0 0 4 2 4 1 1 2 2 4 1 1 2 4 1 1 1 4...
result:
ok ok, up to 6 steps were used
Test #3:
score: 0
Accepted
time: 50ms
memory: 3776kb
input:
10000 10 2 7 5 6 4 8 3 1 10 9 8 10 6 1 5 6 4 7 10 2 6 8 7 6 5 3 9 8 10 4 10 6 1 8 3 9 5 7 2 3 10 9 10 5 10 4 6 10 8 10 4 7 10 4 2 4 1 10 9 7 5 10 3 8 2 6 1 4 10 3 9 3 6 3 7 3 4 3 2 3 5 2 3 8 3 1 10 10 9 5 6 3 4 8 7 2 1 2 6 7 8 5 2 4 9 9 3 3 8 8 5 6 10 4 1 10 2 1 6 7 10 3 4 9 8 5 10 3 3 5 1 3 3 2 3 9...
output:
8 2 5 2 1 6 2 1 2 2 5 6 2 7 9 3 4 1 3 3 7 9 8 1 4 11 2 1 9 2 1 4 1 6 2 8 1 1 6 2 7 4 1 2 1 7 1 5 1 3 1 5 12 1 6 2 7 4 1 6 1 9 1 2 1 9 1 8 1 3 1 8 1 5 1 1 1 5 10 5 8 3 2 5 9 3 1 6 4 4 8 7 5 9 3 3 6 4 4 1 7 5 9 4 8 3 6 4 4 1 7 5 9 4 8 3 6 4 4 1 7 5 9 2 6 4 13 1...
result:
ok ok, up to 15 steps were used
Test #4:
score: 0
Accepted
time: 41ms
memory: 3908kb
input:
2500 20 19 16 18 14 10 3 6 8 9 20 11 1 13 5 4 17 12 15 7 2 14 9 11 1 7 16 9 5 3 1 16 19 15 4 6 9 7 2 12 15 8 5 20 19 16 9 18 1 1 17 1 15 13 15 9 10 1 19 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 5 14 6 10 12 14 9 1 13 1 18 15 7 10 7 12 17 4 4 5 16 9 11 10 18 8 13 19 6 20 2 4 3 4 15 11 8 ...
output:
11 4 8 6 7 15 3 12 3 16 4 13 9 19 10 2 18 6 2 13 19 3 1 6 5 4 12 4 3 14 3 18 9 16 2 8 19 1 15 1 19 0 0 22 8 2 1 6 11 3 5 12 14 7 17 19 4 15 18 9 13 8 2 1 6 11 3 8 12 14 5 19 4 18 9 10 6 1 6 11 5 12 13 6 19 4 8 18 14 10 6 6 11 15 5 9 13 7 19 4 3 8 12 14 10 6 6 11 15 18 9 13 7 16 1...
result:
ok ok, up to 28 steps were used
Test #5:
score: 0
Accepted
time: 33ms
memory: 4072kb
input:
400 50 18 35 3 1 22 2 29 14 27 44 32 4 34 43 33 23 21 48 13 47 46 50 38 12 49 9 11 31 10 8 37 41 42 36 17 15 45 16 24 40 25 30 19 28 7 39 5 20 6 26 45 32 39 28 27 43 29 39 34 40 17 12 8 38 3 23 5 41 40 8 36 43 41 25 19 1 18 43 1 46 28 4 39 11 42 20 44 40 35 43 50 43 15 9 31 20 35 37 22 42 29 30 21 2...
output:
42 12 9 7 5 47 34 20 48 6 32 27 2 8 11 31 28 7 29 11 18 6 22 27 38 35 9 44 7 19 11 18 43 6 27 2 8 9 7 47 18 21 6 27 38 8 31 28 7 18 3 43 6 27 7 44 7 48 21 6 27 35 8 46 7 11 18 43 6 17 27 8 12 7 23 48 21 49 27 35 7 12 7 3 43 6 32 4 6 12 7 48 21 26 35 8 12 7 47 45 18 3 17 27 9 12 7 19 48 21...
result:
ok ok, up to 72 steps were used
Test #6:
score: 0
Accepted
time: 33ms
memory: 4072kb
input:
400 50 16 19 35 42 20 8 28 6 25 15 49 31 24 34 10 1 50 33 2 5 26 46 27 13 9 21 23 7 30 29 12 44 18 14 3 40 45 48 43 36 47 4 39 32 37 22 41 38 11 17 13 24 1 43 6 10 12 47 21 47 17 13 2 20 10 8 35 33 5 13 1 20 23 40 13 14 47 9 49 2 42 41 10 42 8 3 27 34 42 29 46 48 46 14 23 42 1 36 26 31 33 14 2 50 7 ...
output:
39 11 7 28 48 25 23 47 30 33 6 36 2 13 24 7 5 9 25 12 38 32 17 18 21 46 40 13 44 7 14 28 9 25 23 47 18 33 22 45 39 14 19 7 9 25 12 38 32 17 18 21 13 36 39 2 10 24 7 9 25 20 18 33 42 45 39 11 44 7 9 25 23 32 8 35 46 39 2 12 19 27 11 9 25 12 47 17 18 22 45 39 10 7 9 25 12 38 16 21 46 39 2 10 2...
result:
ok ok, up to 73 steps were used
Test #7:
score: 0
Accepted
time: 27ms
memory: 4280kb
input:
100 100 49 90 5 62 95 42 92 16 74 58 66 85 21 98 15 6 73 13 40 78 44 2 93 11 54 76 80 34 89 96 31 56 67 77 79 39 26 14 23 81 3 69 37 97 83 25 12 22 61 48 17 84 35 47 36 53 7 91 60 100 82 57 4 99 45 28 70 72 59 86 33 64 75 41 94 51 29 46 20 8 24 52 1 43 19 27 38 10 55 68 32 71 65 9 30 88 18 87 63 50 ...
output:
79 29 36 47 71 78 33 72 91 7 73 9 6 26 96 45 61 5 50 15 2 66 74 4 10 41 75 85 95 86 35 20 25 54 19 46 23 13 68 52 45 20 5 15 30 66 67 4 44 43 24 39 16 87 36 19 82 1 6 16 63 5 15 66 64 29 22 43 24 16 87 54 19 90 82 13 52 45 5 15 66 64 22 43 24 8 15 87 54 19 59 82 1 68 16 5 15 66 22 44 43 24 16 8...
result:
ok ok, up to 145 steps were used
Test #8:
score: 0
Accepted
time: 35ms
memory: 4516kb
input:
100 100 86 35 82 12 83 29 60 50 90 33 87 4 47 51 70 96 48 31 89 84 92 37 55 94 78 80 57 46 6 99 18 74 10 38 2 63 22 34 67 77 72 44 68 42 79 28 13 17 62 8 14 91 97 98 23 66 27 69 100 7 75 49 36 73 88 56 39 43 58 15 85 41 64 32 61 95 40 25 45 26 93 3 5 20 71 1 11 65 19 9 52 21 81 24 76 16 53 54 30 59 ...
output:
86 24 43 10 6 74 4 97 91 51 62 69 83 86 3 60 67 66 96 81 48 45 50 27 32 21 14 46 68 85 25 47 31 79 61 92 81 19 78 65 17 16 46 99 58 91 51 31 80 67 96 52 57 18 50 34 36 17 14 46 68 74 53 33 76 83 31 79 52 50 34 36 17 13 46 99 98 25 47 31 77 52 22 50 34 36 17 16 46 68 85 88 76 51 83 31 80 3 81 48...
result:
ok ok, up to 141 steps were used
Test #9:
score: 0
Accepted
time: 34ms
memory: 8680kb
input:
1 1000 852 223 408 154 361 680 77 982 706 853 792 191 955 586 379 419 503 697 500 694 599 90 782 234 186 750 322 213 91 315 882 420 605 177 968 269 175 386 69 825 488 696 58 316 877 885 375 872 589 109 75 263 442 760 273 663 547 43 426 372 844 579 425 777 865 878 409 466 39 286 538 726 771 401 51 75...
output:
806 244 919 957 856 841 571 608 517 662 159 424 71 572 325 667 912 295 907 586 28 981 485 461 598 321 131 688 406 704 613 748 181 151 655 890 197 116 618 294 119 255 558 109 980 275 878 665 835 483 466 871 737 278 15 324 33 430 342 475 762 694 729 815 581 592 292 264 308 135 437 247 417 564 115 682 ...
result:
ok ok, up to 806 steps were used
Test #10:
score: 0
Accepted
time: 37ms
memory: 8308kb
input:
1 1000 690 995 868 467 793 949 539 17 557 637 246 77 677 681 714 642 40 43 69 594 433 612 283 865 152 907 30 486 979 253 139 227 810 478 932 439 202 508 388 901 705 821 822 209 920 725 133 469 165 205 16 403 598 858 198 81 954 600 7 387 335 178 658 859 115 905 166 55 127 745 738 144 511 383 648 452 ...
output:
684 303 113 355 853 974 210 942 469 690 77 783 665 737 193 964 490 601 699 981 866 509 69 637 159 114 99 344 675 309 960 365 160 196 325 579 682 662 796 415 707 855 852 758 885 60 823 712 225 494 810 414 232 203 757 543 518 188 286 201 471 438 184 372 910 241 311 427 566 799 722 401 53 9 713 522 383...
result:
ok ok, up to 684 steps were used
Test #11:
score: 0
Accepted
time: 36ms
memory: 8408kb
input:
1 1000 981 206 539 504 568 390 696 919 303 771 71 524 891 51 96 748 158 236 88 633 652 740 616 762 348 636 53 479 509 409 557 920 738 326 224 592 898 867 522 530 953 939 793 657 819 1 110 500 200 170 559 435 627 589 560 551 359 323 787 30 239 783 650 442 969 68 459 830 966 380 630 482 550 352 14 929...
output:
630 311 644 436 187 772 298 906 666 690 761 891 98 235 773 587 474 208 874 512 577 537 352 502 240 755 737 916 209 924 751 194 854 815 631 746 771 637 596 166 752 74 304 322 378 508 135 665 922 122 938 233 523 853 867 82 374 535 188 255 163 65 700 982 76 798 481 428 50 445 742 914 884 140 331 886 92...
result:
ok ok, up to 630 steps were used
Test #12:
score: 0
Accepted
time: 60ms
memory: 9536kb
input:
1 1000 327 708 701 120 714 171 723 70 98 93 402 303 137 145 936 525 741 99 328 656 48 553 753 783 945 254 547 405 823 842 844 822 690 206 436 6 919 560 267 886 613 147 810 908 771 130 407 893 578 439 929 426 59 879 738 770 156 651 323 119 697 357 884 599 990 347 172 590 545 438 223 677 663 363 115 2...
output:
846 334 132 833 412 247 719 935 726 119 83 252 597 234 642 165 776 624 468 326 853 895 948 669 954 570 859 37 958 201 778 299 113 332 490 685 598 82 647 863 555 757 96 15 705 611 795 421 751 829 406 5 585 270 487 698 594 76 742 586 875 196 23 288 424 877 262 881 222 539 46 472 474 606 81 782 159 384...
result:
ok ok, up to 846 steps were used
Test #13:
score: 0
Accepted
time: 65ms
memory: 9284kb
input:
1 1000 332 858 822 192 770 336 467 401 841 606 399 550 239 834 383 300 497 970 19 542 688 478 994 273 553 541 676 654 667 348 904 906 986 21 997 900 437 684 568 44 634 216 120 333 123 231 42 631 488 442 435 824 12 93 774 877 203 490 15 565 151 413 567 782 777 484 861 206 188 707 334 374 99 136 178 5...
output:
966 363 601 59 251 103 20 25 790 526 471 258 879 532 341 803 714 382 4 379 799 145 904 503 511 510 64 328 778 701 209 17 999 567 473 9 16 843 371 706 300 192 235 206 882 405 466 265 782 708 275 745 244 24 429 210 254 277 919 181 663 67 352 126 168 214 449 439 797 174 823 299 924 453 311 683 842 448 ...
result:
ok ok, up to 966 steps were used
Test #14:
score: 0
Accepted
time: 28ms
memory: 8076kb
input:
1 1000 115 372 488 59 513 596 934 677 862 54 696 855 901 825 265 417 899 693 490 203 536 735 402 875 289 510 793 522 199 695 25 726 710 422 137 572 274 881 374 755 163 295 343 219 888 205 597 454 806 39 782 138 889 344 858 160 7 72 185 815 820 830 968 795 691 217 271 772 646 546 840 998 520 670 777 ...
output:
950 95 707 303 865 552 717 837 997 509 101 197 878 885 964 653 140 726 926 505 436 700 222 815 180 311 924 592 32 392 946 510 956 514 268 560 892 448 838 888 377 685 166 563 314 894 989 730 515 741 851 919 661 423 993 332 366 975 879 438 966 723 223 936 775 322 987 954 375 242 971 800 791 253 750 95...
result:
ok ok, up to 950 steps were used
Test #15:
score: 0
Accepted
time: 23ms
memory: 8004kb
input:
1 1000 717 305 986 429 917 628 985 204 341 749 852 307 820 711 484 562 866 473 800 40 241 127 71 565 310 808 480 925 987 250 755 125 848 535 479 295 383 188 375 640 646 466 842 813 752 203 704 831 919 315 994 817 676 386 157 830 374 355 795 60 995 758 814 745 778 681 964 1 279 512 636 862 665 298 68...
output:
958 35 904 999 481 973 943 993 812 897 638 654 442 899 50 785 968 690 786 506 184 996 868 21 905 951 568 995 877 154 997 658 565 794 750 637 239 31 859 999 906 943 993 812 761 638 654 801 50 785 968 786 506 184 996 843 21 905 656 995 877 67 984 658 565 755 750 637 239 31 859 999 158 943 993 835 76...
result:
ok ok, up to 958 steps were used
Test #16:
score: 0
Accepted
time: 30ms
memory: 7912kb
input:
1 1000 310 363 446 303 748 979 8 485 694 948 702 771 36 191 666 891 559 413 845 895 827 67 498 658 971 868 473 674 913 421 65 377 692 536 802 467 237 292 22 967 732 660 275 490 690 672 128 577 833 107 810 353 392 958 824 15 158 243 901 991 717 344 904 565 350 881 641 512 898 159 633 999 422 501 528 ...
output:
985 5 471 707 986 932 933 4 705 834 417 933 4 705 834 599 933 4 778 705 834 933 4 705 834 126 933 4 705 834 92 933 4 705 834 576 933 4 705 834 172 933 4 763 705 834 933 4 705 834 124 933 4 785 705 834 933 4 705 834 409 933 4 705 649 834 933 4 705 834 481 933 4 984 705 834 933 4 705 83...
result:
ok ok, up to 985 steps were used
Test #17:
score: 0
Accepted
time: 29ms
memory: 8252kb
input:
1 1000 77 278 871 920 284 552 661 728 2 158 428 62 898 909 18 496 195 754 63 957 946 772 703 82 394 806 701 197 941 758 665 573 982 308 736 389 423 616 416 530 874 618 494 436 322 939 447 631 391 136 208 985 681 424 529 393 595 19 841 30 461 605 440 132 587 825 848 869 107 512 364 169 872 679 849 75...
output:
1005 1 880 1 181 1 732 1 155 1 201 1 493 1 39 1 663 1 242 1 425 1 696 1 728 1 394 1 642 1 436 1 5 1 123 1 483 1 589 1 395 1 667 1 579 1 513 1 423 1 411 1 994 1 817 1 958 1 275 1 424 1 28 1 941 1 264 1 568 1 621 1 901 1 646 1 252 1 991 1 778 1 509 1 12 1 928 ...
result:
ok ok, up to 1005 steps were used
Test #18:
score: 0
Accepted
time: 33ms
memory: 8368kb
input:
1 999 977 98 254 594 144 861 64 706 322 185 959 376 323 840 42 799 653 762 698 150 162 58 530 189 649 112 430 341 515 303 837 657 344 232 290 867 137 352 716 755 488 15 919 250 49 597 127 420 45 693 314 384 170 745 536 312 178 22 141 79 266 84 80 7 545 210 616 748 843 225 487 588 418 229 414 689 575...
output:
831 257 176 809 329 127 301 551 423 241 707 9 665 620 249 875 49 978 35 939 217 511 806 162 487 816 714 918 283 810 986 857 622 862 595 338 493 536 498 545 12 433 590 245 741 947 98 530 845 436 958 53 997 52 606 71 435 819 961 202 494 349 207 785 119 485 380 246 458 350 727 151 411 293 803 492 54 28...
result:
ok ok, up to 831 steps were used
Test #19:
score: 0
Accepted
time: 38ms
memory: 8400kb
input:
1 999 266 532 27 286 491 460 989 270 745 828 710 910 428 608 178 855 803 851 719 938 627 684 584 661 547 827 3 641 771 223 567 241 275 476 933 417 287 705 545 272 904 572 747 92 589 168 384 613 928 237 936 728 870 349 724 183 617 624 626 240 508 354 538 578 133 190 477 787 308 120 323 590 798 664 11...
output:
723 300 659 164 591 416 896 846 727 828 781 396 60 644 473 271 194 697 493 243 16 625 796 873 376 658 61 443 741 536 484 267 288 120 642 564 171 639 624 848 337 499 653 437 325 711 800 253 672 373 178 121 667 755 674 336 685 803 874 780 990 22 128 928 32 264 830 736 328 746 346 233 276 274 49 831 12...
result:
ok ok, up to 723 steps were used
Test #20:
score: 0
Accepted
time: 42ms
memory: 8832kb
input:
1 999 32 791 286 948 176 560 246 200 367 339 179 369 474 328 772 886 982 954 604 262 944 602 491 965 585 408 970 638 686 896 769 1 873 703 444 658 348 96 891 514 118 78 52 904 469 851 956 468 996 299 64 43 311 539 738 927 788 224 959 79 141 940 967 51 376 244 343 350 379 949 421 844 382 775 465 414 ...
output:
1004 332 911 880 890 521 163 689 970 790 331 825 904 818 9 982 752 802 218 945 152 433 406 884 690 317 478 948 975 494 56 144 646 768 931 498 552 26 730 869 140 280 489 318 823 889 497 676 32 516 212 533 915 549 352 276 287 383 919 740 824 364 928 956 612 738 557 814 555 131 209 762 370 20 930 580 3...
result:
ok ok, up to 1004 steps were used
Test #21:
score: 0
Accepted
time: 80ms
memory: 10192kb
input:
1 999 162 333 835 598 275 157 150 732 33 26 263 815 589 327 515 530 581 239 565 251 126 705 855 155 382 10 406 185 599 802 445 661 9 600 74 574 163 952 474 462 340 125 250 137 992 660 727 407 486 226 612 287 658 945 82 399 416 939 171 838 120 644 194 114 752 831 351 413 96 316 317 946 109 35 318 692...
output:
1166 441 23 510 716 679 150 554 441 119 155 96 932 749 508 659 610 486 17 791 730 490 38 505 819 93 35 693 599 573 173 608 618 200 115 68 534 697 305 157 406 312 929 322 963 934 992 361 818 75 506 766 242 60 199 769 637 228 901 178 843 107 695 957 27 504 956 193 744 696 297 643 533 81 79 278 194 895...
result:
ok ok, up to 1166 steps were used
Test #22:
score: 0
Accepted
time: 83ms
memory: 10240kb
input:
1 999 709 23 572 330 7 668 5 576 217 663 840 634 47 731 182 724 413 574 38 225 459 739 2 609 234 281 537 76 718 403 800 529 979 913 75 661 134 19 83 445 90 810 248 583 348 478 13 695 392 623 894 550 631 523 783 373 111 431 425 652 487 253 719 98 854 711 130 588 686 159 903 753 836 222 35 28 749 817 ...
output:
999 499 19 168 827 402 359 366 163 331 553 889 315 856 283 414 819 285 194 20 301 510 978 719 642 472 888 893 199 796 493 226 678 867 684 690 671 883 304 956 379 403 458 915 217 665 703 426 596 60 758 626 246 245 864 263 398 397 368 620 494 875 18 329 457 849 506 256 775 95 983 565 562 771 545 570 3...
result:
ok ok, up to 999 steps were used
Test #23:
score: 0
Accepted
time: 25ms
memory: 8204kb
input:
1 999 719 626 485 972 276 492 226 237 77 102 843 188 386 650 123 976 24 861 233 391 973 29 543 17 172 468 927 588 22 141 119 566 98 700 769 282 271 432 956 995 692 837 308 848 180 216 442 482 451 793 913 942 362 463 729 64 983 965 986 259 345 890 534 56 152 450 266 647 300 326 759 900 254 929 786 35...
output:
988 95 984 732 416 854 174 965 8 745 950 921 902 539 120 109 510 356 710 874 941 900 917 123 600 966 4 945 459 160 367 955 749 839 834 932 511 635 328 756 809 159 959 881 85 518 764 723 973 614 199 618 257 930 442 59 255 974 985 916 891 254 864 679 216 244 942 954 274 448 632 855 733 915 479 166 772...
result:
ok ok, up to 988 steps were used
Test #24:
score: 0
Accepted
time: 29ms
memory: 8064kb
input:
1 999 759 723 437 606 248 905 512 502 912 612 469 81 971 736 446 481 888 903 672 823 229 900 959 148 532 220 225 849 241 943 88 263 810 228 915 45 934 167 89 879 782 859 315 426 36 252 451 142 604 894 910 549 677 561 57 476 55 427 682 652 120 352 779 292 289 815 996 590 923 435 796 366 855 181 507 9...
output:
1094 25 998 994 576 989 693 990 949 282 991 995 830 904 639 987 200 572 962 751 933 432 935 838 908 932 906 24 998 458 576 989 668 976 949 282 991 937 830 904 639 500 200 962 751 933 432 935 838 908 932 906 24 361 576 989 668 976 949 282 991 937 830 904 639 176 200 962 751 933 432 935 838 908 932 ...
result:
ok ok, up to 1094 steps were used
Test #25:
score: 0
Accepted
time: 36ms
memory: 7944kb
input:
1 999 920 435 55 749 629 95 418 187 971 806 239 760 641 396 219 47 777 413 500 229 271 182 571 754 162 624 935 790 755 646 739 447 341 949 485 236 193 363 315 633 463 656 852 129 126 696 16 710 961 542 59 156 483 841 3 246 992 972 51 947 651 969 405 516 85 821 71 487 848 98 67 857 709 281 895 825 14...
output:
1423 5 995 898 610 696 881 5 420 610 696 602 314 5 889 610 696 646 314 5 193 610 696 927 989 5 889 610 696 927 314 4 898 610 696 602 5 995 420 610 696 927 4 610 696 903 989 5 889 610 696 903 278 5 420 610 696 903 989 6 964 869 610 696 903 881 5 956 610 696 903 989 6 956 610 696 903 194 2...
result:
ok ok, up to 1423 steps were used
Test #26:
score: 0
Accepted
time: 41ms
memory: 8004kb
input:
1 999 311 242 610 99 258 592 164 715 179 45 161 139 499 398 738 170 404 234 445 395 63 33 968 301 323 568 938 447 721 855 584 645 22 601 300 710 279 923 700 265 380 489 853 613 10 297 166 574 324 278 152 407 263 187 117 798 340 470 202 221 411 622 21 876 820 659 261 885 405 905 831 289 126 237 825 2...
output:
1495 1 467 1 930 1 279 1 930 1 998 1 622 1 998 1 997 1 282 1 997 1 996 1 929 1 996 1 995 1 570 1 995 1 994 1 817 1 994 1 993 1 182 1 993 1 992 1 957 1 992 1 991 1 967 1 991 1 990 1 887 1 990 1 989 1 451 1 989 1 988 1 795 1 988 1 987 1 940 1 987 1 986 1 186 1...
result:
ok ok, up to 1495 steps were used
Test #27:
score: 0
Accepted
time: 30ms
memory: 8300kb
input:
1 998 948 460 335 899 872 723 754 646 789 772 119 382 651 383 942 755 774 997 446 970 867 949 471 67 935 391 875 632 727 992 366 915 369 88 207 889 918 511 526 138 792 384 967 388 162 661 179 375 304 897 559 368 688 907 267 531 787 573 817 943 530 278 677 814 327 850 24 606 339 37 435 578 75 169 73 ...
output:
728 266 551 374 731 209 382 326 623 740 732 238 401 379 162 318 239 465 766 249 963 83 79 437 385 164 629 190 423 864 786 443 714 765 772 687 34 863 213 879 502 371 126 797 932 129 927 574 991 925 611 554 832 138 276 945 867 519 543 94 804 904 760 12 838 476 53 820 648 102 347 207 107 114 35 887 541...
result:
ok ok, up to 728 steps were used
Test #28:
score: 0
Accepted
time: 31ms
memory: 8620kb
input:
1 998 494 391 49 950 498 165 692 300 510 673 931 837 954 352 465 197 719 959 328 896 303 198 461 729 298 887 437 549 445 696 457 955 378 552 765 73 180 383 103 980 321 852 194 345 105 513 471 538 3 527 878 708 732 148 913 833 806 894 111 897 816 790 828 947 858 604 388 142 517 455 367 632 36 240 396...
output:
765 303 844 641 446 308 477 247 223 15 60 993 285 742 710 347 291 368 695 65 678 137 366 324 416 664 838 173 370 722 934 525 989 129 107 881 951 508 221 143 561 112 814 119 797 440 441 126 259 839 301 214 684 823 320 995 748 967 390 344 62 185 746 239 26 83 920 804 644 526 810 646 3 775 396 890 95 4...
result:
ok ok, up to 765 steps were used
Test #29:
score: 0
Accepted
time: 46ms
memory: 8916kb
input:
1 998 765 850 400 698 96 680 434 963 388 616 398 505 511 25 611 887 550 641 153 736 743 946 908 659 14 595 984 939 332 937 373 792 787 251 150 617 767 809 990 477 959 953 380 358 789 462 987 348 227 929 931 168 510 452 823 387 627 614 62 466 529 59 449 410 711 758 649 158 541 403 531 475 968 795 412...
output:
1003 336 807 997 347 802 617 345 542 349 373 650 514 236 93 463 826 844 396 341 327 737 888 65 791 350 460 116 911 117 97 822 124 934 313 834 852 854 531 320 184 845 918 565 863 506 953 39 326 842 805 282 612 381 354 482 293 414 735 551 541 96 156 48 861 408 161 471 479 402 342 860 416 902 570 195 4...
result:
ok ok, up to 1003 steps were used
Test #30:
score: 0
Accepted
time: 75ms
memory: 9932kb
input:
1 998 627 431 727 497 487 126 684 838 644 15 516 818 127 44 10 657 823 189 63 115 939 963 873 607 346 706 608 79 210 461 392 243 454 227 647 565 774 851 478 625 141 910 177 14 239 317 498 543 457 294 893 531 132 234 492 804 92 585 908 116 678 674 19 583 856 403 595 688 554 797 223 596 789 295 438 24...
output:
1138 447 844 599 469 762 299 39 86 734 503 641 612 34 211 137 424 341 333 366 316 927 498 937 301 924 446 521 973 363 587 26 400 634 821 329 565 991 989 835 182 920 138 660 853 311 766 695 250 615 925 522 633 534 505 691 806 524 670 68 331 628 914 650 174 127 813 857 442 796 195 36 226 51 957 536 77...
result:
ok ok, up to 1138 steps were used
Test #31:
score: 0
Accepted
time: 74ms
memory: 9996kb
input:
1 998 733 959 347 569 526 485 632 134 887 320 369 825 92 463 536 915 808 805 589 982 537 826 812 336 647 686 638 884 36 841 243 429 687 855 483 29 293 140 892 280 94 750 682 816 394 791 676 186 913 339 766 945 655 960 718 480 866 974 85 121 849 188 206 933 604 517 820 553 476 313 370 420 964 193 528...
output:
1000 497 385 561 17 864 808 399 161 251 964 845 217 877 468 323 621 818 579 16 995 458 1 388 414 20 562 698 568 169 951 859 518 300 958 99 413 973 701 391 65 167 456 285 861 867 351 926 200 306 229 759 772 526 797 535 387 105 218 330 534 894 597 644 565 159 892 721 726 327 923 354 294 136 667 175 36...
result:
ok ok, up to 1000 steps were used
Test #32:
score: 0
Accepted
time: 30ms
memory: 8172kb
input:
1 998 238 368 91 13 760 72 419 694 981 177 883 447 4 329 902 810 141 624 473 919 916 507 778 923 701 863 657 812 200 832 256 605 472 974 301 328 515 304 481 62 176 297 891 345 661 769 889 595 488 422 849 276 954 644 897 708 960 333 236 240 326 40 485 564 782 896 79 197 187 869 136 6 830 828 60 788 4...
output:
964 84 965 659 781 406 456 265 913 168 979 885 799 837 881 615 801 114 289 436 977 556 654 934 892 661 629 731 688 889 336 235 800 945 970 310 983 571 422 767 667 262 516 478 111 603 937 873 868 455 819 404 987 183 988 726 927 893 745 652 166 741 823 728 320 441 115 810 825 526 23 862 188 718 876 10...
result:
ok ok, up to 964 steps were used
Test #33:
score: 0
Accepted
time: 29ms
memory: 8084kb
input:
1 998 657 220 904 795 418 211 522 176 489 271 647 237 700 935 594 194 535 136 835 286 259 838 858 551 906 623 502 154 508 141 742 797 863 682 500 920 299 899 850 642 68 495 689 282 656 735 745 796 181 593 894 929 783 723 713 414 260 314 354 668 563 193 727 768 845 996 625 41 376 296 983 235 677 840 ...
output:
1068 27 939 967 192 748 989 445 877 982 489 976 532 975 438 388 673 501 980 871 965 923 520 955 930 920 990 964 664 27 939 621 192 748 989 445 877 956 807 976 532 975 367 388 673 501 980 871 212 923 520 870 930 920 990 964 664 26 939 621 192 748 770 445 877 956 976 532 975 367 388 673 501 980 871 ...
result:
ok ok, up to 1068 steps were used
Test #34:
score: 0
Accepted
time: 36ms
memory: 8276kb
input:
1 998 571 670 211 487 704 982 672 742 89 547 852 953 925 808 256 92 828 807 288 236 815 570 430 408 434 407 426 447 763 310 694 720 706 870 36 35 61 622 479 791 46 208 944 933 389 41 417 514 504 712 106 543 343 143 992 134 793 891 613 630 37 234 616 93 589 887 212 544 345 477 945 113 866 278 853 814...
output:
1415 4 641 996 987 901 3 987 901 185 4 198 745 987 901 4 305 120 901 437 5 584 355 926 901 437 4 584 120 901 437 4 745 987 901 437 5 584 609 973 901 437 4 316 973 901 437 3 973 901 185 4 641 996 973 901 4 995 973 901 437 3 973 901 185 4 603 973 901 22 3 973 901 185 4 995 973 901 437 ...
result:
ok ok, up to 1415 steps were used
Test #35:
score: 0
Accepted
time: 38ms
memory: 7872kb
input:
1 998 648 130 748 548 766 651 270 645 672 196 25 141 588 538 622 530 658 580 763 359 794 476 341 579 11 614 893 255 703 612 569 290 232 446 393 323 535 371 821 870 281 157 518 148 325 619 986 138 434 807 923 626 714 250 239 209 620 309 945 829 347 360 118 173 367 693 571 957 599 568 725 973 488 936 ...
output:
1488 1 67 1 510 1 46 1 510 1 997 1 389 1 997 1 996 1 687 1 996 1 995 1 640 1 995 1 994 1 692 1 994 1 993 1 347 1 993 1 992 1 240 1 992 1 991 1 132 1 991 1 990 1 375 1 990 1 989 1 685 1 989 1 988 1 272 1 551 1 168 1 988 1 987 1 381 1 987 1 986 1 888 1 986 1 9...
result:
ok ok, up to 1488 steps were used
Test #36:
score: 0
Accepted
time: 1ms
memory: 5848kb
input:
1 1 1
output:
0
result:
ok ok, up to 0 steps were used
Test #37:
score: 0
Accepted
time: 30ms
memory: 3984kb
input:
400 48 43 47 8 20 36 13 35 3 23 34 15 48 6 31 11 44 27 33 37 4 46 40 9 28 29 41 17 24 25 32 14 30 18 10 7 5 19 45 42 22 26 39 1 16 38 21 2 12 10 29 29 17 13 3 42 26 5 26 37 41 6 40 16 19 12 26 38 23 7 39 11 33 10 39 43 39 20 10 35 18 45 14 5 21 34 6 38 39 8 45 26 25 9 12 33 15 37 9 45 3 48 1 47 21 3...
output:
34 15 47 33 15 45 10 36 24 26 29 41 39 6 9 32 27 9 7 1 12 21 31 6 23 5 34 10 47 33 13 36 17 3 39 6 9 43 8 20 1 31 42 6 23 5 34 9 10 13 36 3 30 39 6 9 43 7 45 1 8 6 23 18 34 7 13 36 41 39 6 5 43 7 20 1 41 6 9 18 34 8 35 10 36 41 6 23 5 43 8 33 1 41 39 6 9 18 34 8 19 35 36 8 6 23 5 43 9 33 ...
result:
ok ok, up to 71 steps were used
Test #38:
score: 0
Accepted
time: 26ms
memory: 8508kb
input:
3 1 1 986 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 926 925 924 923 922 921 920 919 918 917 916 915 91...
output:
0 757 362 15 19 17 25 21 39 38 34 33 32 28 58 57 51 49 47 46 40 91 89 87 86 85 78 74 72 70 68 67 66 60 144 140 138 136 134 133 126 125 121 120 119 115 112 108 106 104 102 101 93 234 233 229 228 227 223 220 216 214 212 210 209 208 200 199 193 191 189 188 182 181 180 176 175 174 170 167 163 161 159 15...
result:
ok ok, up to 757 steps were used
Test #39:
score: 0
Accepted
time: 26ms
memory: 8280kb
input:
3 1 1 986 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 926 925 924 923 922 921 920 919 918 917 916 915 91...
output:
0 757 362 983 977 975 973 972 965 964 960 959 958 954 951 947 945 943 941 940 930 928 926 925 924 917 913 911 909 907 906 905 899 897 896 890 888 886 885 879 878 877 873 872 871 867 864 860 858 856 854 853 842 841 837 836 835 831 828 824 822 820 818 817 816 808 807 801 799 797 796 790 789 788 784 78...
result:
ok ok, up to 757 steps were used
Test #40:
score: 0
Accepted
time: 22ms
memory: 8376kb
input:
3 1 1 986 973 974 972 975 970 971 976 967 968 966 969 977 962 963 961 964 959 960 965 978 954 955 953 956 951 952 957 948 949 947 950 958 979 941 942 940 943 938 939 944 935 936 934 937 945 930 931 929 932 927 928 933 946 980 920 921 919 922 917 918 923 914 915 913 916 924 909 910 908 911 906 907 91...
output:
0 757 386 16 20 19 27 23 21 38 36 34 33 32 59 56 54 51 49 47 44 40 90 88 85 83 81 80 78 77 74 72 70 68 67 66 146 144 143 140 137 135 132 130 124 122 119 117 115 114 111 109 106 104 102 99 93 233 231 229 226 221 220 219 213 211 208 206 204 202 200 199 198 193 191 190 188 187 182 179 177 174 172 170 1...
result:
ok ok, up to 757 steps were used
Test #41:
score: 0
Accepted
time: 26ms
memory: 8560kb
input:
3 1 1 986 986 985 983 984 981 980 982 978 977 975 976 979 973 972 970 971 968 967 969 974 965 964 962 963 960 959 961 957 956 954 955 958 966 952 951 949 950 947 946 948 944 943 941 942 945 939 938 936 937 934 933 935 940 953 931 930 928 929 926 925 927 923 922 920 921 924 918 917 915 916 913 912 91...
output:
0 764 321 14 15 20 26 25 39 38 32 30 28 59 56 54 51 49 45 43 40 88 85 83 81 77 75 73 72 68 65 62 142 140 137 135 131 123 121 118 114 111 108 106 104 102 99 94 231 229 226 222 218 210 207 204 202 201 198 195 193 191 189 186 177 174 172 170 166 164 162 161 157 156 155 151 376 375 374 370 369 365 364 3...
result:
ok ok, up to 764 steps were used
Test #42:
score: 0
Accepted
time: 6ms
memory: 7792kb
input:
3 1 1 986 2 1 7 3 6 5 4 20 8 11 10 9 19 13 12 18 14 17 16 15 54 21 24 23 22 32 26 25 31 27 30 29 28 53 34 33 39 35 38 37 36 52 40 43 42 41 51 45 44 50 46 49 48 47 143 55 58 57 56 66 60 59 65 61 64 63 62 87 68 67 73 69 72 71 70 86 74 77 76 75 85 79 78 84 80 83 82 81 142 89 88 94 90 93 92 91 107 95 98...
output:
0 30 349 985 982 980 978 977 974 972 971 967 965 964 961 959 958 955 953 951 950 946 945 941 940 939 933 931 930 927 925 924 921 919 917 916 912 911 907 906 905 900 898 896 895 891 890 886 885 884 878 877 873 872 871 865 864 863 856 854 851 847 844 842 841 838 836 835 832 830 828 827 823 822 818 817...
result:
ok ok, up to 30 steps were used
Test #43:
score: 0
Accepted
time: 26ms
memory: 8536kb
input:
3 1 1 986 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 926 925 924 923 922 921 920 919 918 917 916 915 91...
output:
0 761 328 20 19 27 22 39 38 30 59 54 52 51 43 40 92 91 88 85 83 80 77 75 73 72 67 66 62 60 146 141 139 138 130 127 126 125 117 114 109 107 106 101 100 95 234 233 230 227 225 222 219 217 215 214 206 204 202 200 198 192 185 183 181 180 177 174 172 169 166 164 162 161 154 151 149 377 372 370 369 361 35...
result:
ok ok, up to 761 steps were used
Test #44:
score: 0
Accepted
time: 27ms
memory: 8316kb
input:
3 1 1 986 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 926 925 924 923 922 921 920 919 918 917 916 915 91...
output:
0 813 331 973 972 971 966 965 960 959 958 954 953 951 950 947 946 941 940 939 929 926 919 917 916 913 909 907 906 905 899 897 894 886 885 884 879 878 873 872 871 867 866 864 863 860 859 854 853 852 842 841 831 830 828 827 824 820 818 817 816 808 805 798 796 795 791 787 784 777 775 774 771 767 765 76...
result:
ok ok, up to 813 steps were used
Test #45:
score: 0
Accepted
time: 20ms
memory: 7876kb
input:
1 1000 996 43 577 950 687 195 887 640 567 684 142 595 290 471 322 5 885 318 272 246 98 607 931 578 718 867 45 676 655 616 650 222 367 615 31 385 203 834 488 437 710 603 804 392 713 399 311 70 847 617 513 411 575 695 347 431 463 216 77 306 295 144 566 475 270 933 897 892 706 954 526 440 240 919 974 7...
output:
667 334 97 943 946 699 878 591 695 419 940 612 917 705 290 903 432 272 740 451 865 230 305 777 642 149 378 187 40 688 302 681 291 422 921 883 222 170 849 262 784 614 787 185 351 29 512 395 365 418 181 409 851 282 702 131 803 426 956 265 129 528 846 195 964 627 410 555 990 678 657 342 923 557 132 366...
result:
ok ok, up to 667 steps were used
Test #46:
score: 0
Accepted
time: 24ms
memory: 7876kb
input:
1 1000 107 95 790 410 138 13 486 51 36 3 226 569 961 785 273 822 628 927 699 802 255 856 441 499 246 751 534 187 257 935 505 562 575 217 567 767 351 315 178 476 532 144 182 111 511 112 479 830 70 834 551 266 69 636 501 541 128 504 125 708 278 969 97 872 52 945 538 949 784 821 341 168 232 988 154 437...
output:
667 1 331 1 810 2 765 405 1 305 2 937 493 1 481 2 382 128 1 876 2 304 631 1 484 2 363 7 1 697 2 853 68 1 320 2 203 191 1 130 2 630 160 1 136 2 341 746 1 888 2 997 14 1 408 2 467 573 1 705 2 856 771 1 401 2 941 113 1 513 2 851 32 1 605 2 747 910 1 757 2 830 428 1 882 ...
result:
ok ok, up to 667 steps were used
Test #47:
score: 0
Accepted
time: 24ms
memory: 8156kb
input:
1 1000 657 131 1 655 428 7 948 767 429 296 26 667 74 3 804 399 782 796 260 295 719 724 378 56 708 570 442 500 896 403 861 937 833 616 379 812 95 457 122 293 210 917 162 342 22 189 963 949 14 766 933 847 199 117 911 612 424 274 791 6 671 715 805 564 718 542 928 416 11 314 315 891 494 906 120 829 173 ...
output:
667 1 999 1 608 2 734 619 1 844 2 582 576 1 492 2 513 917 1 652 2 655 259 1 337 2 788 828 1 561 2 797 232 1 763 2 399 426 1 683 2 695 278 1 966 2 787 89 1 949 2 24 349 1 81 2 918 467 1 123 2 646 903 1 452 2 5 239 1 130 2 174 837 1 49 2 950 817 1 716 2 714 44 1 181 2...
result:
ok ok, up to 667 steps were used
Test #48:
score: 0
Accepted
time: 24ms
memory: 8156kb
input:
1 1000 291 378 38 938 62 810 402 752 333 22 916 737 852 709 865 667 686 954 716 419 876 191 853 829 841 904 296 471 387 151 823 167 7 455 509 719 325 4 893 235 570 204 206 196 911 16 366 638 303 903 885 414 948 102 715 50 334 593 444 774 635 819 362 990 642 730 541 65 901 493 271 377 857 170 586 252...
output:
667 334 891 618 398 876 843 984 131 622 11 190 411 865 90 928 686 948 115 636 99 516 39 176 664 562 192 777 977 226 292 34 324 391 145 733 265 980 339 86 975 898 278 542 634 881 763 272 323 496 800 888 690 947 578 509 129 566 650 814 435 850 616 285 627 219 998 71 922 446 426 979 743 1 169 771 428 5...
result:
ok ok, up to 667 steps were used
Extra Test:
score: 0
Extra Test Passed