QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#826754#9772. Permutation Routingucup-team3586AC ✓79ms9840kbC++232.7kb2024-12-22 15:53:332025-01-10 11:38:54

Judging History

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

  • [2025-01-10 11:38:54]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:AC
  • 用时:79ms
  • 内存:9840kb
  • [2025-01-10 11:38:24]
  • hack成功,自动添加数据
  • (/hack/1438)
  • [2024-12-22 15:53:40]
  • 评测
  • 测评结果:100
  • 用时:80ms
  • 内存:9848kb
  • [2024-12-22 15:53:33]
  • 提交

answer

//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
int n;
vector<pii> G[1005];
int p[1005];
int dist[1005][1005];
void dfs(int u,int fa,int d,int *di)
{
	di[u]=d;
	for(auto pr:G[u])
	{
		int v=pr.first;
		if(v!=fa)
			dfs(v,u,d+1,di);
	}
}
vector<vector<int>> Answer;
int check()
{
	for(int i=1;i<=n;i++)
		if(p[i]!=i)
			return 0;
	return 1;
}
inline int sqr(int x){return x*x;}
int cost[1005];
int f[1005],g[1005];
pii ind[1005];
void dfs(int u,int fa)
{
	f[u]=-inf;
	g[u]=0;
	for(auto pr:G[u])
		if(pr.first!=fa)
		{
			dfs(pr.first,u);
			g[u]+=max(f[pr.first],g[pr.first]);
		}
	for(auto pr:G[u])
		if(pr.first!=fa)
		{
			int val=cost[pr.second]+g[u]-max(f[pr.first],g[pr.first])+g[pr.first];
			if(val>f[u])
			{
				f[u]=val;
				ind[u]=pr;
			}
		}
}
vector<int> Edges;
void construct(int u,int fa);
void constructF(int u,int fa);
void constructG(int u,int fa);
void construct(int u,int fa)
{
	if(f[u]>g[u]) constructF(u,fa);
	else constructG(u,fa);
}
void constructF(int u,int fa)
{
	Edges.pb(ind[u].second);
	swap(p[u],p[ind[u].first]);
	for(auto pr:G[u])
		if(pr.first!=fa)
			(pr==ind[u]?constructG:construct)(pr.first,u);
}
void constructG(int u,int fa)
{
	for(auto pr:G[u])
		if(pr.first!=fa)
			construct(pr.first,u);
}
void op()
{
	Edges.clear();
	for(int i=1;i<n;i++) cost[i]=0;
	for(int i=1;i<=n;i++)
		for(auto pr:G[i])
		{
			int j=pr.first;
			cost[pr.second]+=sqr(dist[i][p[i]])-sqr(dist[j][p[i]]);
		}
	dfs(1,0);
	construct(1,0);
	Answer.pb(Edges);
}
void solve()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		G[i].clear();
	for(int i=1;i<=n;i++)
		cin>>p[i];
	for(int i=1;i<n;i++)
	{
		int u,v;
		cin>>u>>v;
		G[u].pb(v,i);
		G[v].pb(u,i);
	}
	for(int i=1;i<=n;i++)
		dfs(i,0,0,dist[i]);
	Answer.clear();
	while(!check())
		op();
	cout<<sz(Answer)<<'\n';
	for(auto arr:Answer)
	{
		cout<<sz(arr)<<" ";
		for(auto E:arr)
			cout<<E<<" ";
		cout<<'\n';
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--)
		solve();
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 14ms
memory: 3612kb

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:

5
1 2 
1 3 
1 1 
1 4 
1 1 
0
1
2 3 1 
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 2 
1 1 
1 2 
6
1 2 
1 3 
1 2 
1 1 
1 4 
1 1 
3
1 2 
2 1 4 
1 2 
3
1 1 
1 4 
1 2 
0
5
2 2 1 
2 4 3 
2 2 1 
2 4 3 
2 2 1 
4
2 3 2 
1 1 
2 3 2 
1 1 
1
2 1 2 
0
0
0
4
2 1 4 
1 2 
2 1 4 
1 2 
4
1 ...

result:

ok ok, up to 6 steps were used

Test #3:

score: 0
Accepted
time: 51ms
memory: 3860kb

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:

7
2 6 5 
2 2 1 
2 6 5 
2 7 1 
4 3 9 5 4 
3 7 8 1 
1 4 
10
1 4 
1 6 
2 8 1 
1 6 
2 4 2 
2 9 7 
1 2 
1 3 
1 5 
1 3 
12
1 6 
2 4 7 
1 6 
1 1 
1 5 
1 1 
1 2 
1 9 
1 2 
1 3 
1 8 
1 3 
10
5 9 5 2 3 8 
3 4 7 1 
4 9 6 3 8 
3 5 7 1 
4 4 6 3 8 
4 9 5 7 1 
4 4 6 3 8 
4 9 5 7 1 
4 4 6 3 8 
2 7 1 
13
1 6 
1 1 
1...

result:

ok ok, up to 13 steps were used

Test #4:

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

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:

12
4 15 7 6 8 
3 16 12 3 
3 10 13 9 
2 6 18 
2 19 3 
3 5 13 9 
2 14 6 
3 16 12 13 
2 15 1 
2 19 4 
2 15 18 
1 8 
0
0
22
8 11 14 12 5 3 6 1 17 
7 13 9 18 15 4 19 2 
8 11 14 12 8 3 6 1 17 
5 10 9 5 4 19 
6 11 13 18 8 6 1 
6 10 14 12 5 4 19 
6 11 13 9 18 8 6 
7 10 14 12 5 15 4 19 
7 11 13 9 18 8 3 6 
7...

result:

ok ok, up to 28 steps were used

Test #5:

score: 0
Accepted
time: 26ms
memory: 3860kb

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:

40
9 47 8 2 32 11 48 34 5 9 
5 35 38 22 28 31 
3 43 2 44 
4 47 38 21 9 
4 43 3 28 31 
4 35 21 48 44 
5 43 17 20 18 9 
7 35 32 21 23 29 12 31 
4 43 4 22 3 
4 35 26 21 48 
4 47 17 3 18 
6 43 2 49 14 48 19 
5 35 6 21 25 10 
4 43 4 3 7 
4 35 27 20 48 
5 47 2 21 25 24 
6 43 4 16 20 34 19 
5 35 21 24 28 1...

result:

ok ok, up to 71 steps were used

Test #6:

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

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:

43
8 2 36 6 33 18 23 47 48 
8 24 40 46 21 17 32 38 5 
8 45 22 33 20 47 14 28 44 
7 2 13 21 23 32 38 19 
6 24 46 35 17 47 12 
6 45 26 33 20 38 44 
7 2 22 8 23 32 48 19 
8 11 46 21 17 30 47 9 5 
7 31 45 22 33 38 28 7 
6 2 46 21 17 37 27 
5 24 45 22 33 16 
6 11 40 46 21 17 44 
7 45 39 22 33 23 7 43 
6 ...

result:

ok ok, up to 71 steps were used

Test #7:

score: 0
Accepted
time: 26ms
memory: 4116kb

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
24 35 86 70 41 95 24 85 10 74 61 2 50 52 26 6 9 91 73 7 72 78 33 47 36 
12 87 54 68 44 22 30 20 51 13 23 46 25 
4 63 4 90 36 
3 8 45 91 
4 68 44 16 3 
5 8 10 52 90 72 
7 68 44 67 96 51 91 98 
6 37 11 10 29 90 3 
7 68 34 22 30 14 46 72 
6 63 4 79 90 62 76 
4 68 50 81 91 
6 8 45 26 6 57 46 
5 68 44...

result:

ok ok, up to 141 steps were used

Test #8:

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

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:

87
19 21 27 50 45 74 83 48 96 66 60 3 86 69 62 51 97 4 10 43 
9 78 34 61 19 13 79 47 25 68 
7 83 57 67 80 51 76 99 
6 22 79 9 53 33 90 
5 83 48 77 44 98 
8 18 19 52 60 3 47 42 88 
5 78 83 16 69 51 
4 36 18 47 25 
5 21 78 83 51 76 
6 36 17 18 47 25 5 
6 21 32 78 83 51 76 
8 17 63 27 18 47 33 91 90 
7...

result:

ok ok, up to 141 steps were used

Test #9:

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

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:

804
208 957 807 868 856 298 562 456 182 816 254 865 279 233 673 657 752 271 993 472 419 19 813 877 89 864 245 400 395 348 136 556 510 239 304 743 882 432 940 280 637 221 338 906 213 423 525 428 977 53 210 470 540 563 869 641 789 646 130 106 814 120 2 366 463 588 354 718 85 780 821 336 904 69 265 583...

result:

ok ok, up to 804 steps were used

Test #10:

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

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:

690
296 425 980 661 732 727 316 882 435 343 892 482 468 32 371 541 231 679 755 616 395 631 644 46 185 120 527 658 94 51 421 942 13 535 317 938 819 747 589 83 304 804 795 384 728 721 323 501 843 23 650 850 406 534 239 356 105 254 392 200 626 391 19 725 549 677 610 258 445 923 943 499 556 525 772 837 ...

result:

ok ok, up to 690 steps were used

Test #11:

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

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:

631
310 289 148 564 830 509 971 618 601 373 900 913 470 113 389 823 337 494 681 501 191 939 453 650 708 466 363 420 206 663 339 678 81 549 260 662 647 505 223 747 284 961 36 346 204 367 105 607 227 733 46 569 377 902 659 465 973 238 396 85 648 139 879 170 34 580 964 340 720 297 402 731 236 261 3 151...

result:

ok ok, up to 631 steps were used

Test #12:

score: 0
Accepted
time: 51ms
memory: 8560kb

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:

844
334 64 12 129 964 495 318 987 675 203 584 220 634 187 271 722 529 25 720 471 236 259 808 791 688 366 932 354 648 8 235 470 683 857 658 870 342 966 656 975 71 788 850 914 141 232 459 747 701 844 826 346 537 369 652 686 246 269 528 976 239 357 676 765 824 827 375 57 563 149 272 561 336 433 381 393...

result:

ok ok, up to 844 steps were used

Test #13:

score: 0
Accepted
time: 66ms
memory: 8908kb

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 395 550 220 720 195 315 447 680 336 263 249 695 519 499 332 62 971 903 886 558 741 992 884 543 859 486 403 73 83 636 595 956 780 306 752 845 46 984 18 789 814 31 975 873 245 864 287 191 467 440 943 890 113 881 533 132 568 316 569 337 921 269 285 194 833 583 43 585 474 792 39 487 551 329 675 ...

result:

ok ok, up to 966 steps were used

Test #14:

score: 0
Accepted
time: 18ms
memory: 7636kb

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:

952
59 23 843 252 931 515 291 118 20 949 58 912 797 89 9 253 17 95 131 125 987 223 49 668 366 226 154 210 919 21 741 730 28 615 888 838 448 560 105 5 385 338 518 392 32 331 34 311 180 222 436 505 140 73 352 119 469 101 717 59 
4 207 533 909 155 
3 903 89 241 
3 771 175 627 
3 276 541 277 
3 771 637 ...

result:

ok ok, up to 952 steps were used

Test #15:

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

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:

960
12 154 1 3 568 204 2 690 46 442 190 481 42 
2 906 67 
2 198 158 
2 154 571 
3 986 224 272 
2 906 290 
3 37 108 45 
3 535 800 25 
3 713 29 557 
3 154 24 917 
3 986 652 128 
2 154 809 
2 368 20 
1 906 
2 535 26 
2 850 868 
2 154 845 
3 906 841 77 
3 110 35 30 
2 535 543 
2 906 193 
2 597 48 
2 154...

result:

ok ok, up to 960 steps were used

Test #16:

score: 0
Accepted
time: 18ms
memory: 7928kb

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:

986
4 707 143 261 471 
1 417 
1 599 
1 778 
1 126 
1 92 
1 576 
1 172 
1 763 
1 124 
1 785 
1 409 
1 649 
1 481 
1 984 
1 381 
1 60 
1 424 
1 198 
1 285 
1 828 
1 825 
1 311 
1 855 
1 890 
1 133 
1 675 
1 819 
1 444 
1 544 
1 306 
1 814 
1 298 
1 698 
1 955 
1 667 
1 852 
1 431 
1 590 
1 404 
1 630 ...

result:

ok ok, up to 986 steps were used

Test #17:

score: 0
Accepted
time: 18ms
memory: 7644kb

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: 24ms
memory: 7652kb

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:

837
223 765 360 503 406 409 276 444 400 929 65 94 427 308 968 853 188 174 104 787 953 271 165 146 529 535 367 852 739 632 2 491 742 883 84 544 377 440 108 232 933 970 24 420 303 373 686 628 85 434 607 534 648 359 722 832 940 426 892 746 738 198 667 674 79 345 23 981 470 734 141 170 361 695 649 59 39...

result:

ok ok, up to 837 steps were used

Test #19:

score: 0
Accepted
time: 37ms
memory: 7752kb

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:

726
284 762 57 187 316 455 732 887 776 840 207 131 181 261 897 623 829 847 460 549 919 754 384 938 48 694 104 876 522 313 980 724 856 731 306 506 972 816 143 744 778 807 986 689 531 101 520 395 578 404 589 64 810 402 12 145 54 397 577 733 285 612 681 631 357 86 176 428 124 768 527 52 696 492 338 165...

result:

ok ok, up to 726 steps were used

Test #20:

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

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:

1006
303 911 969 239 639 238 759 763 320 263 625 479 291 754 166 568 254 181 290 841 481 86 867 960 849 399 593 27 34 753 932 686 654 458 282 442 134 151 966 933 707 774 943 979 257 71 176 236 445 52 875 850 33 227 286 172 161 356 971 476 295 632 502 204 954 312 380 833 358 804 876 394 585 403 451 6...

result:

ok ok, up to 1006 steps were used

Test #21:

score: 0
Accepted
time: 79ms
memory: 9236kb

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:

1159
419 958 521 162 232 825 158 385 754 205 889 997 717 728 528 720 580 753 25 291 738 294 951 520 904 109 444 396 711 670 883 970 739 550 692 858 272 458 966 135 920 303 980 416 977 145 24 141 780 412 387 748 206 931 662 89 638 781 939 651 56 369 644 916 721 252 386 414 701 893 814 820 793 362 264...

result:

ok ok, up to 1159 steps were used

Test #22:

score: 0
Accepted
time: 75ms
memory: 9328kb

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:

1000
499 460 219 696 526 129 316 895 221 702 583 858 787 417 961 14 555 387 396 932 512 167 365 122 209 720 39 249 123 416 144 45 297 443 423 56 154 25 934 880 463 908 338 814 629 940 347 905 102 422 145 51 554 292 196 641 471 778 793 784 909 290 425 861 746 147 505 968 31 866 647 609 126 185 717 15...

result:

ok ok, up to 1000 steps were used

Test #23:

score: 0
Accepted
time: 18ms
memory: 7640kb

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:

984
38 635 34 792 581 78 778 400 272 946 165 451 166 830 261 242 181 448 274 255 226 529 48 171 85 159 809 756 834 24 686 459 237 701 356 169 96 921 854 
3 338 901 573 
2 888 14 
3 256 162 136 
3 14 558 441 
3 27 579 790 
3 14 175 755 
4 195 386 142 915 
3 691 60 654 
3 14 520 209 
3 682 873 88 
5 1...

result:

ok ok, up to 984 steps were used

Test #24:

score: 0
Accepted
time: 15ms
memory: 7976kb

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:

1102
5 9 572 5 12 668 
1 500 
2 190 292 
2 500 595 
3 9 77 661 
2 13 7 
1 979 
2 899 137 
3 426 147 253 
3 190 430 60 
3 381 211 2 
3 682 86 608 
2 586 699 
3 678 234 282 
3 899 400 463 
3 426 20 295 
3 500 691 233 
2 632 842 
2 426 144 
2 899 494 
2 944 60 
3 10 426 335 
2 632 896 
3 500 63 5 
3 42...

result:

ok ok, up to 1102 steps were used

Test #25:

score: 0
Accepted
time: 23ms
memory: 7776kb

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:

1424
3 314 7 420 
1 989 
2 584 889 
2 989 420 
3 314 7 898 
2 881 9 
1 989 
2 303 889 
2 989 898 
3 881 9 20 
1 34 
1 889 
2 489 294 
1 889 
2 34 20 
2 35 54 
1 989 
2 398 194 
1 989 
2 15 35 
1 37 
1 989 
2 835 718 
1 989 
2 15 37 
2 16 38 
1 989 
2 135 735 
1 989 
2 16 38 
2 28 42 
1 889 
2 57 375...

result:

ok ok, up to 1424 steps were used

Test #26:

score: 0
Accepted
time: 19ms
memory: 7672kb

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 1 
1 634 
1 1 
1 2 
1 129 
1 2 
1 3 
1 465 
1 3 
1 4 
1 868 
1 4 
1 5 
1 865 
1 5 
1 6 
1 349 
1 6 
1 7 
1 505 
1 7 
1 8 
1 158 
1 8 
1 9 
1 274 
1 9 
1 10 
1 141 
1 10 
1 11 
1 510 
1 11 
1 12 
1 960 
1 12 
1 13 
1 764 
1 13 
1 14 
1 788 
1 14 
1 15 
1 961 
1 15 
1 16 
1 371 
1 16 
1 ...

result:

ok ok, up to 1495 steps were used

Test #27:

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

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:

734
227 881 659 496 984 975 644 16 775 583 330 27 758 618 139 447 254 645 215 193 411 896 545 137 954 793 125 752 746 785 409 958 847 419 461 794 895 327 988 36 957 279 550 566 601 360 485 480 870 329 271 756 65 450 528 31 264 449 782 607 392 198 777 348 533 22 69 926 708 91 338 141 412 174 62 277 7...

result:

ok ok, up to 734 steps were used

Test #28:

score: 0
Accepted
time: 37ms
memory: 7776kb

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:

771
288 822 986 608 909 576 630 348 42 544 631 985 360 270 873 627 921 698 857 780 617 678 711 355 747 577 691 937 127 153 659 599 410 18 521 773 315 217 683 840 730 486 541 699 597 91 330 265 788 938 36 827 948 356 690 543 58 893 879 182 310 550 931 858 322 557 336 103 600 736 764 340 518 655 880 1...

result:

ok ok, up to 771 steps were used

Test #29:

score: 0
Accepted
time: 48ms
memory: 7988kb

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:

1001
301 807 136 595 693 669 808 4 605 860 129 465 570 199 426 294 269 840 680 323 163 926 564 549 78 594 753 942 427 521 683 331 457 123 491 606 583 864 448 398 382 603 7 223 994 694 109 749 507 189 257 483 674 823 689 964 105 971 979 233 378 474 311 284 487 817 86 851 133 920 324 260 301 607 319 4...

result:

ok ok, up to 1001 steps were used

Test #30:

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

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:

1126
431 629 40 193 582 9 404 868 213 126 959 87 375 899 187 70 538 283 310 905 198 752 383 288 596 179 220 750 157 61 282 154 765 197 100 413 230 241 6 523 577 414 373 931 662 113 289 955 122 882 940 576 758 535 438 423 826 782 63 281 45 224 656 148 901 231 808 143 377 653 449 573 32 623 381 362 25...

result:

ok ok, up to 1126 steps were used

Test #31:

score: 0
Accepted
time: 79ms
memory: 9840kb

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 304 689 896 969 53 931 422 392 328 312 582 617 6 298 93 194 386 846 420 569 113 286 343 652 120 788 367 311 264 241 408 848 508 30 447 706 811 479 287 359 988 400 511 901 984 51 978 373 197 662 909 135 347 880 916 282 204 406 669 215 461 78 903 56 141 676 153 54 427 280 49 645 581 266 628 7...

result:

ok ok, up to 1000 steps were used

Test #32:

score: 0
Accepted
time: 17ms
memory: 7688kb

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:

974
38 191 596 832 568 214 229 115 58 27 47 217 166 893 927 697 183 5 106 983 111 262 667 164 30 336 889 629 147 14 436 135 179 161 302 417 168 913 265 
2 808 264 
4 8 7 574 250 
3 413 802 308 
3 986 156 675 
3 413 139 206 
3 596 255 417 
4 472 413 937 837 
3 89 298 433 
4 596 75 471 770 
3 648 774 ...

result:

ok ok, up to 974 steps were used

Test #33:

score: 0
Accepted
time: 19ms
memory: 7728kb

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:

1077
5 489 60 367 28 590 
2 212 807 
2 442 826 
3 368 78 273 
3 770 339 6 
2 442 605 
3 672 309 49 
3 48 866 13 
2 561 471 
2 143 263 
3 138 955 183 
2 442 930 
2 38 683 
3 143 562 40 
2 561 548 
3 38 110 28 
3 442 124 226 
2 672 13 
2 632 442 
2 770 6 
3 38 46 54 
2 561 840 
2 442 183 
3 262 350 28...

result:

ok ok, up to 1077 steps were used

Test #34:

score: 0
Accepted
time: 23ms
memory: 7928kb

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:

1413
2 641 7 
1 185 
2 88 745 
2 120 305 
2 918 926 
1 120 
2 745 26 
2 609 584 
1 316 
1 185 
2 641 7 
2 4 20 
1 185 
2 588 123 
1 185 
2 4 20 
2 13 35 
1 185 
2 407 69 
1 185 
2 13 35 
2 14 41 
1 659 
2 185 704 
2 481 203 
1 185 
2 14 659 
3 19 41 839 
1 48 
1 185 
2 828 534 
1 185 
2 19 48 
2 21 ...

result:

ok ok, up to 1413 steps were used

Test #35:

score: 0
Accepted
time: 20ms
memory: 7900kb

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 1 
1 763 
1 1 
1 2 
1 643 
1 2 
1 3 
1 237 
1 3 
1 4 
1 449 
1 4 
1 5 
1 614 
1 5 
1 6 
1 809 
1 6 
1 7 
1 117 
1 7 
1 8 
1 118 
1 8 
1 9 
1 314 
1 9 
1 10 
1 292 
1 10 
1 11 
1 432 
1 11 
1 12 
1 259 
1 12 
1 13 
1 485 
1 13 
1 14 
1 887 
1 14 
1 15 
1 499 
1 15 
1 16 
1 724 
1 16 
1 1...

result:

ok ok, up to 1488 steps were used

Test #36:

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

input:

1
1
1

output:

0

result:

ok ok, up to 0 steps were used

Test #37:

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

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:

33
14 27 36 32 29 9 39 41 26 24 15 45 10 33 47 
7 34 5 23 17 12 1 7 
7 36 43 9 39 13 33 47 
6 34 18 23 42 1 20 
7 36 43 5 39 30 13 10 
6 34 18 9 8 1 45 
5 37 43 5 23 13 
7 27 34 18 9 39 35 11 
5 36 43 5 23 20 
5 34 18 9 39 1 
6 36 43 5 23 8 35 
8 34 18 4 40 42 41 1 33 
7 36 43 5 23 30 13 7 
7 34 18 ...

result:

ok ok, up to 70 steps were used

Test #38:

score: 0
Accepted
time: 19ms
memory: 7876kb

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
758
374 14 15 17 28 40 60 147 235 1 843 612 668 648 616 625 623 620 627 634 631 644 642 641 640 646 657 655 652 659 666 663 670 676 675 674 681 680 687 684 697 695 694 693 699 735 703 712 710 707 714 721 718 731 729 728 727 733 744 742 739 746 753 750 810 790 778 759 765 764 763 770 769 776 773 78...

result:

ok ok, up to 758 steps were used

Test #39:

score: 0
Accepted
time: 19ms
memory: 7660kb

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
374 984 966 843 1 235 4 60 40 8 17 15 12 19 26 23 36 34 33 32 38 49 47 44 51 58 55 62 68 67 66 73 72 79 76 89 87 86 85 91 127 95 104 102 99 106 113 110 123 121 120 119 125 136 134 131 138 145 142 202 182 170 151 157 156 155 162 161 168 165 176 175 174 181 180 191 189 186 193 200 197 204 210 20...

result:

ok ok, up to 757 steps were used

Test #40:

score: 0
Accepted
time: 15ms
memory: 7900kb

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
765
333 13 11 21 40 93 235 610 612 614 616 625 620 627 630 632 635 638 640 643 645 661 651 653 656 658 665 667 670 672 674 677 679 687 685 697 695 692 699 735 716 706 708 711 713 720 722 731 729 726 733 737 741 743 746 753 751 757 759 761 763 766 768 776 774 786 784 781 788 791 797 795 802 808 805...

result:

ok ok, up to 765 steps were used

Test #41:

score: 0
Accepted
time: 19ms
memory: 7612kb

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
761
252 14 15 9 1 625 623 622 630 635 642 639 661 652 656 658 663 676 675 674 684 688 695 692 698 716 709 708 711 713 718 729 728 727 732 741 740 747 746 753 752 751 765 764 773 777 784 781 787 803 796 795 798 800 805 818 817 816 821 828 827 839 836 835 838 841 860 853 855 857 862 873 872 871 876 ...

result:

ok ok, up to 761 steps were used

Test #42:

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

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
32
327 985 980 2 4 7 21 17 15 14 13 24 36 34 32 49 47 45 58 55 61 70 68 66 79 76 89 87 84 95 104 102 100 113 110 123 121 118 136 134 131 145 144 143 148 150 159 157 155 168 165 178 176 173 191 189 186 200 199 198 203 212 210 207 221 220 219 229 228 234 233 237 239 248 246 244 257 254 267 265 262 2...

result:

ok ok, up to 32 steps were used

Test #43:

score: 0
Accepted
time: 15ms
memory: 7832kb

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
764
214 40 60 1 668 648 621 627 635 638 647 651 659 667 675 681 683 685 688 691 693 696 700 735 709 714 722 725 734 738 746 754 810 762 770 772 774 777 780 782 785 789 793 808 806 814 823 825 827 830 833 835 838 842 899 879 851 858 866 869 878 882 890 898 906 912 914 916 919 922 924 927 931 966 94...

result:

ok ok, up to 764 steps were used

Test #44:

score: 0
Accepted
time: 19ms
memory: 7832kb

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
825
255 610 3 60 40 8 15 14 13 20 24 27 33 32 35 47 46 45 58 55 67 66 69 77 80 90 127 95 102 101 100 107 111 114 120 119 122 134 133 132 145 144 143 150 156 155 158 166 169 179 183 187 190 200 197 203 209 208 211 219 222 234 233 291 271 239 246 245 244 251 255 258 264 263 266 278 277 276 289 286 2...

result:

ok ok, up to 825 steps were used

Test #45:

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

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 5 863 32 341 712 26 246 895 53 345 516 941 153 618 463 766 121 467 135 541 737 227 216 955 694 819 65 13 278 141 442 588 985 499 791 200 441 509 462 1 136 765 816 92 779 682 515 389 296 698 714 750 337 69 806 747 275 981 402 255 931 224 728 822 143 348 631 794 843 446 440 448 110 833 906 203...

result:

ok ok, up to 667 steps were used

Test #46:

score: 0
Accepted
time: 15ms
memory: 7696kb

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 3 
1 36 
2 965 223 
1 313 
2 951 328 
1 225 
2 766 414 
1 760 
2 922 60 
1 119 
2 171 462 
1 443 
2 921 63 
1 425 
2 71 544 
1 34 
2 143 761 
1 274 
2 466 824 
1 691 
2 441 739 
1 245 
2 472 560 
1 177 
2 699 19 
1 772 
2 85 730 
1 607 
2 863 787 
1 987 
2 449 295 
1 202 
2 353 514 
1 943 
2 1...

result:

ok ok, up to 667 steps were used

Test #47:

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

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 2 
1 987 
2 818 233 
1 286 
2 691 775 
1 20 
2 863 200 
1 73 
2 308 974 
1 53 
2 709 391 
1 603 
2 890 196 
1 637 
2 813 805 
1 413 
2 82 223 
1 984 
2 641 295 
1 592 
2 311 347 
1 214 
2 959 65 
1 768 
2 240 626 
1 839 
2 221 894 
1 54 
2 209 721 
1 113 
2 783 920 
1 577 
2 325 77 
1 70 
2 87...

result:

ok ok, up to 667 steps were used

Test #48:

score: 0
Accepted
time: 15ms
memory: 7728kb

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 2 862 303 286 924 402 270 725 44 209 910 361 780 833 264 32 702 830 817 629 534 175 104 400 195 682 314 521 654 642 757 417 951 649 326 113 430 867 957 82 225 105 357 715 485 61 232 630 716 754 539 440 260 340 25 358 372 639 333 518 227 123 962 87 905 551 766 895 972 21 287 676 88 394 644 96...

result:

ok ok, up to 667 steps were used

Extra Test:

score: 0
Extra Test Passed