QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#615293#9432. PermutationzhouhuanyiAC ✓281ms3900kbC++231.8kb2024-10-05 18:00:312024-10-05 18:02:26

Judging History

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

  • [2024-10-05 18:02:26]
  • 评测
  • 测评结果:AC
  • 用时:281ms
  • 内存:3900kb
  • [2024-10-05 18:00:31]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<random>
#include<algorithm>
#define N 1000
using namespace std;
mt19937 RAND(random_device{}());
int n,dp[N+1],sp[N+1],delta[N+1],ans[N+1];
int query()
{
	int d;
	cout<<0<<' ';
	for (int i=1;i<=n;++i) cout<<delta[i]<<' ';
	cout<<endl;
	fflush(stdout);
	cin>>d;
	return d;
}
void solve(int l,int r,vector<int>p)
{
	if (l==r)
	{
		ans[l]=p[0];
		return;
	}
	int d,mid=(l+r)>>1,cnt=mid-l+1,cnt2=r-mid;
	vector<int>A;
	vector<int>B;
	shuffle(p.begin(),p.end(),RAND);
	for (int i=0;i+1<p.size();i+=2)
	{
		for (int j=1;j<=n;++j) delta[j]=sp[j];
		for (int j=l;j<=mid;++j) delta[j]=p[i];
		for (int j=mid+1;j<=r;++j) delta[j]=p[i+1];
		d=query();
		if (!d) A.push_back(p[i+1]),B.push_back(p[i]),cnt--,cnt2--;
		else if (d==2) A.push_back(p[i]),B.push_back(p[i+1]),cnt--,cnt2--;
		else
		{
			for (int j=mid+1;j<=r;++j) delta[j]=sp[j];
			if (cnt2==1) A.push_back(p[i]),A.push_back(p[i+1]),cnt-=2;
			else if (cnt==1) B.push_back(p[i]),B.push_back(p[i+1]),cnt2-=2;
			else if (query()) A.push_back(p[i]),A.push_back(p[i+1]),cnt-=2;
			else B.push_back(p[i]),B.push_back(p[i+1]),cnt2-=2;
		}
		if (!cnt)
		{
			for (int j=i+2;j<p.size();++j) B.push_back(p[j]);
			break;
		}
		if (!cnt2)
		{
			for (int j=i+2;j<p.size();++j) A.push_back(p[j]);
			break;
		}
	}
	solve(l,mid,A),solve(mid+1,r,B);
	return;
}
int main()
{
	cin>>n;
	if (n==1)
	{
		cout<<1<<' '<<1<<endl;
		fflush(stdout);
		return 0;
	}
	while (1)
	{
		for (int i=1;i<=n;++i) delta[i]=RAND()%n+1;
		if (!query()) break;
	}
	for (int i=1;i<=n;++i) sp[i]=delta[i];
	vector<int>p;
	for (int i=1;i<=n;++i) p.push_back(i);
	solve(1,n,p);
	cout<<1<<' ';
	for (int i=1;i<=n;++i) cout<<ans[i]<<' ';
	cout<<endl;
	fflush(stdout);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
2
0
1
1
0
0
0
2

output:

0 4 4 2 3 1 
0 5 3 1 2 2 
0 4 4 4 2 2 
0 4 4 4 2 2 
0 5 5 5 3 3 
0 2 2 4 2 2 
0 4 3 1 2 2 
0 5 3 1 1 5 
1 3 4 2 1 5 

result:

ok Accepted

Test #2:

score: 0
Accepted
time: 250ms
memory: 3856kb

input:

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

output:

0 402 578 430 473 928 422 422 399 730 573 595 748 878 647 569 332 107 90 944 821 435 918 960 764 641 274 520 356 62 547 455 473 177 253 295 801 421 221 293 184 564 358 325 68 432 402 130 410 810 471 126 36 618 983 335 792 882 981 451 799 84 109 212 723 605 647 550 771 307 7 138 754 808 701 183 798 7...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1

result:

ok Accepted

Test #4:

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

input:

2
2
2
1
2
0
2

output:

0 2 1 
0 2 1 
0 1 1 
0 2 1 
0 1 2 
0 2 1 
1 2 1 

result:

ok Accepted

Test #5:

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

input:

3
0
0
2

output:

0 2 3 3 
0 2 2 1 
0 3 1 3 
1 3 1 2 

result:

ok Accepted

Test #6:

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

input:

4
2
1
2
2
1
0
1
0
2
2

output:

0 3 2 3 1 
0 3 1 4 3 
0 3 2 2 2 
0 1 1 2 1 
0 1 1 2 2 
0 1 3 1 3 
0 1 1 2 2 
0 1 1 1 3 
0 3 4 1 3 
0 1 3 2 1 
1 3 4 2 1 

result:

ok Accepted

Test #7:

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

input:

6
3
2
3
0
2
2
0
0
2
0
0

output:

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

result:

ok Accepted

Test #8:

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

input:

7
0
1
0
1
1
0
0
0
0
1
2

output:

0 5 1 6 6 2 3 1 
0 5 5 5 5 4 4 4 
0 5 5 5 5 2 3 1 
0 1 1 1 1 2 2 2 
0 7 7 7 7 3 3 3 
0 1 1 3 3 2 3 1 
0 2 2 7 7 2 3 1 
0 7 3 6 6 2 3 1 
0 5 1 1 2 2 3 1 
0 5 1 6 6 6 6 5 
0 5 1 6 6 6 5 1 
1 3 7 2 1 6 5 4 

result:

ok Accepted

Test #9:

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

input:

8
1
2
2
1
3
0
1
0
0
1
2
1
0
2
0
2
0
2
2

output:

0 6 3 6 3 2 7 2 8 
0 4 1 3 2 1 5 4 7 
0 6 7 1 6 7 8 4 6 
0 7 6 4 7 7 6 5 8 
0 3 7 5 4 4 6 4 3 
0 6 3 5 3 8 7 5 6 
0 6 6 6 6 8 8 8 8 
0 6 6 6 6 8 7 5 6 
0 5 5 5 5 7 7 7 7 
0 3 3 3 3 2 2 2 2 
0 1 1 1 1 4 4 4 4 
0 1 1 2 2 8 7 5 6 
0 1 1 5 3 8 7 5 6 
0 3 7 5 3 8 7 5 6 
0 6 3 1 2 8 7 5 6 
0 6 3 5 3 5 5 8...

result:

ok Accepted

Test #10:

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

input:

9
2
0
0
2
0
0
1
1
1
0
0
0
1
0
0
2

output:

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

result:

ok Accepted

Test #11:

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

input:

10
0
1
1
2
2
0
1
1
1
1
2
2
0
2
0
0
0

output:

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

result:

ok Accepted

Test #12:

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

input:

11
1
1
0
1
1
2
0
0
1
1
1
1
0
1
0
1
2
1
1
1
1
0
2

output:

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

result:

ok Accepted

Test #13:

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

input:

12
2
3
1
1
1
0
2
0
0
0
0
0
1
0
1
2
1
2
2
0
0
2
0
2
0
0
2

output:

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

result:

ok Accepted

Test #14:

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

input:

13
0
1
1
1
0
2
2
2
1
0
2
2
1
1
0
2
0
2
1
1
1
0
1
0
2
2

output:

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

result:

ok Accepted

Test #15:

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

input:

14
2
1
2
2
2
2
2
1
1
0
0
1
0
2
1
1
0
1
0
2
1
1
2
2
2
2
0
0
2
0
1
0
2
2
0
0
1
2

output:

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

result:

ok Accepted

Test #16:

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

input:

15
3
4
0
1
0
1
1
1
1
0
0
0
0
1
0
1
1
1
0
1
1
0
0
1
1
0
0
1
0
1
0
1
1
0
0
2
0

output:

0 14 7 6 9 4 6 3 8 10 1 8 6 13 14 8 
0 14 11 11 10 13 3 4 11 4 12 8 6 1 14 2 
0 6 3 3 9 1 8 6 6 6 4 11 14 1 7 1 
0 5 5 5 5 5 5 5 5 12 12 12 12 12 12 12 
0 5 5 5 5 5 5 5 5 6 4 11 14 1 7 1 
0 9 9 9 9 9 9 9 9 15 15 15 15 15 15 15 
0 9 9 9 9 9 9 9 9 6 4 11 14 1 7 1 
0 1 1 1 1 1 1 1 1 10 10 10 10 10 10 1...

result:

ok Accepted

Test #17:

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

input:

975
2
1
1
0
1
1
1
0
1
1
0
2
1
1
2
1
1
1
0
1
0
1
0
1
1
2
1
0
1
0
2
1
1
0
0
0
0
0
0
0
0
0
1
0
1
0
2
2
1
0
1
1
0
2
2
1
0
2
2
1
0
2
2
1
0
2
2
1
1
1
0
0
2
1
1
0
1
0
1
0
1
1
1
0
1
0
1
1
1
0
2
1
1
1
0
1
0
1
0
0
2
0
0
1
1
2
1
0
1
0
0
0
1
0
1
1
2
1
0
1
1
1
1
0
1
0
1
0
1
1
1
0
1
1
1
0
1
1
0
0
1
0
0
0
2
2
1
0
...

output:

0 324 517 711 609 298 202 834 861 391 125 440 657 297 469 961 850 30 700 586 149 623 380 585 353 463 881 11 408 868 669 389 236 384 825 328 446 759 132 154 601 504 497 16 49 831 862 720 371 410 955 680 353 342 137 861 491 301 888 397 212 962 407 77 958 341 392 715 651 698 904 495 238 91 331 211 283 ...

result:

ok Accepted

Test #18:

score: 0
Accepted
time: 248ms
memory: 3608kb

input:

976
1
2
1
0
1
0
1
0
1
1
1
0
1
0
1
0
1
1
1
1
0
2
2
1
1
1
0
0
2
2
1
0
1
0
1
0
1
1
1
1
1
0
1
0
2
2
1
1
0
1
1
0
1
0
1
0
1
0
2
1
0
2
2
2
2
2
0
1
1
0
1
0
1
1
1
1
1
0
1
1
2
1
1
1
1
1
1
1
0
2
1
0
2
2
1
0
1
1
0
1
0
1
1
1
0
1
0
2
1
1
1
1
0
2
1
1
0
1
0
2
1
1
1
1
2
0
0
1
0
0
2
1
0
0
1
0
0
0
2
0
2
1
1
0
1
0
2
0
...

output:

0 228 348 929 51 312 446 937 476 511 869 93 832 960 651 851 952 613 623 580 228 359 7 473 36 610 268 404 25 473 613 230 197 63 268 827 223 317 450 147 136 104 722 683 690 114 278 859 763 949 706 730 80 312 756 383 366 946 806 333 399 976 393 308 823 185 779 775 565 481 889 931 758 948 210 750 182 42...

result:

ok Accepted

Test #19:

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

input:

977
1
2
3
0
1
0
1
1
1
0
2
1
1
1
0
2
1
0
1
1
2
1
1
1
0
1
0
1
1
1
0
1
0
2
1
0
1
0
1
0
1
0
1
0
0
2
1
1
1
0
0
1
0
1
1
1
1
0
1
0
1
1
0
1
1
1
1
1
1
1
0
2
2
0
1
0
2
1
0
1
1
2
2
2
1
1
1
1
2
1
0
1
1
2
1
1
0
1
1
2
1
0
0
0
2
2
0
1
1
1
0
2
0
0
1
0
1
0
2
0
0
0
0
1
1
1
0
2
0
1
1
1
1
2
1
1
1
1
2
1
0
1
1
2
1
1
1
0
...

output:

0 884 88 173 382 974 611 312 594 505 98 383 447 372 293 218 325 680 670 561 323 70 642 250 916 721 599 733 263 17 27 437 344 677 282 476 89 103 548 475 18 496 394 167 765 665 306 319 795 717 772 244 807 94 251 701 613 738 475 934 745 667 224 258 211 830 850 743 633 670 367 704 461 112 521 575 427 81...

result:

ok Accepted

Test #20:

score: 0
Accepted
time: 223ms
memory: 3600kb

input:

978
1
0
0
1
1
2
1
1
0
1
0
1
1
1
0
0
2
1
1
1
0
1
0
0
2
0
0
2
0
0
1
0
2
1
0
1
0
1
0
2
1
0
1
1
1
0
1
0
2
2
0
2
1
1
0
1
1
0
1
0
1
1
0
0
1
1
2
1
0
0
0
1
1
2
1
0
1
0
2
1
0
1
1
0
0
1
1
1
1
0
1
1
2
1
1
1
0
0
0
2
2
2
1
0
2
1
1
1
1
2
1
1
1
1
2
1
1
0
1
0
2
2
2
1
1
0
1
0
1
1
1
0
1
1
1
1
0
1
0
2
2
1
0
1
1
1
1
0
...

output:

0 608 552 675 693 929 107 449 522 186 114 454 164 295 774 497 240 425 777 444 493 689 97 241 483 907 497 477 683 15 806 954 173 835 563 890 577 460 746 299 760 372 566 61 336 80 741 40 770 713 947 406 298 470 937 570 164 418 152 885 403 422 233 746 783 863 200 533 927 549 559 696 389 486 752 85 103 ...

result:

ok Accepted

Test #21:

score: 0
Accepted
time: 243ms
memory: 3660kb

input:

979
1
0
2
1
1
1
0
0
1
0
0
1
1
2
1
0
0
2
0
0
1
1
0
1
1
0
0
2
1
0
1
1
2
1
1
2
1
0
1
1
1
1
2
1
1
1
0
0
1
1
2
1
1
1
0
1
1
1
0
2
1
1
0
1
0
1
0
1
1
1
0
1
1
0
1
0
2
1
1
1
1
1
0
0
1
0
0
0
1
0
2
0
1
0
0
2
1
1
1
1
1
1
1
1
2
1
0
1
0
0
0
1
0
1
0
2
0
1
0
0
2
2
2
0
1
1
1
1
0
1
0
2
1
1
1
0
2
0
2
1
1
1
0
2
1
0
2
0
...

output:

0 102 628 636 375 404 147 190 29 178 243 945 31 328 549 77 304 316 769 182 800 598 360 887 959 245 367 378 741 340 575 326 208 689 455 216 188 777 449 671 69 541 259 410 948 732 89 759 675 413 902 267 288 886 197 297 113 108 70 970 374 144 792 203 683 373 546 109 632 601 603 693 321 730 175 232 487 ...

result:

ok Accepted

Test #22:

score: 0
Accepted
time: 245ms
memory: 3660kb

input:

980
2
1
1
0
1
0
0
1
0
1
0
2
0
1
0
2
0
2
1
0
0
1
0
1
1
1
0
2
2
0
1
1
2
2
1
0
1
1
0
1
0
1
1
2
1
0
1
1
1
1
1
0
0
0
2
1
1
0
2
2
2
0
0
2
1
0
1
0
2
2
1
0
0
1
0
0
1
0
2
1
1
1
1
0
1
1
1
1
1
1
2
2
1
1
1
0
2
2
1
0
1
1
1
1
1
1
2
2
1
1
2
2
0
0
1
1
0
0
0
2
2
1
0
1
0
1
1
1
1
1
1
2
0
2
2
0
2
1
1
2
1
1
1
0
1
0
2
1
...

output:

0 580 884 384 562 884 884 745 197 751 393 869 378 675 211 853 209 943 192 384 702 751 640 516 2 487 592 382 349 733 602 822 705 682 958 161 562 274 620 833 356 103 754 215 520 870 889 134 59 695 748 868 650 728 618 750 540 536 806 819 942 401 42 859 659 13 667 511 929 612 949 446 693 434 57 903 710 ...

result:

ok Accepted

Test #23:

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

input:

981
1
3
1
3
1
5
1
1
0
2
2
0
1
1
1
1
0
1
1
2
1
0
0
1
0
1
1
0
2
1
1
2
0
0
1
1
1
0
0
1
0
2
0
0
1
1
0
1
1
1
0
1
1
1
1
1
1
2
1
1
1
0
0
0
0
2
2
0
2
1
0
1
0
2
1
0
0
1
1
0
1
0
2
2
0
1
1
1
1
2
1
1
2
1
1
0
1
0
1
0
1
1
2
1
1
1
1
1
0
1
1
1
0
2
2
1
0
1
1
1
0
0
1
0
1
1
1
0
1
0
0
2
1
1
2
1
1
1
0
1
1
1
1
2
2
0
1
1
...

output:

0 620 759 204 95 826 312 862 575 802 169 449 287 458 135 139 424 83 716 845 504 534 446 766 647 279 588 712 667 162 573 459 697 976 837 776 942 584 690 790 174 590 878 628 56 334 955 898 241 301 198 181 194 933 538 943 717 435 837 133 702 974 71 604 450 271 863 295 786 137 87 250 395 822 405 694 798...

result:

ok Accepted

Test #24:

score: 0
Accepted
time: 255ms
memory: 3544kb

input:

982
3
0
1
1
2
1
1
1
1
1
1
0
1
1
0
1
1
2
1
1
0
1
1
1
1
0
1
0
2
0
0
0
1
0
1
0
0
1
0
0
0
2
0
2
0
2
1
1
0
1
1
1
0
1
1
1
0
0
1
1
2
1
1
0
1
1
0
2
0
2
2
1
0
2
0
2
1
0
1
1
0
2
1
0
1
1
1
0
0
0
1
0
1
0
1
0
2
2
1
1
1
0
2
0
1
1
2
2
1
1
0
2
2
1
0
1
0
2
2
1
1
0
1
1
2
0
1
0
0
1
1
1
0
1
1
1
0
1
0
0
1
0
0
2
2
1
0
2
...

output:

0 50 387 348 168 350 329 586 910 335 709 896 438 91 291 807 747 111 14 343 348 838 685 215 483 847 424 23 85 916 336 256 707 151 516 608 578 623 743 961 77 173 595 592 336 559 234 590 234 152 375 610 52 342 186 903 519 53 626 679 710 94 38 801 105 370 878 693 501 248 810 855 621 971 192 657 40 115 6...

result:

ok Accepted

Test #25:

score: 0
Accepted
time: 229ms
memory: 3596kb

input:

983
1
1
1
2
2
1
1
0
0
2
0
1
1
0
1
1
0
0
1
0
0
0
2
1
0
1
1
2
1
1
2
1
1
2
0
1
0
1
1
1
0
0
0
0
2
0
0
1
1
0
0
1
0
1
1
1
0
1
0
1
0
0
1
0
0
1
0
1
1
1
1
2
1
0
1
1
1
0
2
1
1
1
0
1
1
1
0
1
0
1
1
2
2
1
0
1
1
1
1
1
0
1
0
0
1
1
1
0
1
1
2
1
1
1
0
1
0
1
1
2
2
1
1
0
1
1
1
0
2
1
1
1
0
1
0
0
1
1
1
0
1
0
1
1
1
0
2
2
...

output:

0 131 390 515 807 579 979 280 684 810 612 41 967 640 574 760 92 271 385 625 210 412 291 278 370 620 61 171 919 911 913 454 87 298 967 352 471 906 342 418 770 141 818 791 296 785 616 667 941 785 858 94 978 835 463 40 769 176 806 443 768 469 208 213 701 289 913 365 866 192 65 729 377 784 425 417 443 6...

result:

ok Accepted

Test #26:

score: 0
Accepted
time: 252ms
memory: 3696kb

input:

984
0
1
1
2
1
1
0
1
1
0
2
2
0
1
0
1
1
0
0
0
0
1
1
1
0
1
1
2
0
1
1
1
0
2
1
0
0
0
0
2
2
2
1
1
1
0
2
0
1
1
0
1
0
0
2
2
1
1
1
1
2
1
0
1
0
1
1
1
1
2
2
1
1
1
1
1
1
0
0
0
2
2
2
1
1
1
0
0
1
0
1
0
0
2
2
2
1
0
1
1
1
0
1
0
2
0
1
0
1
0
2
1
1
1
1
1
1
1
1
1
0
1
0
1
0
1
1
0
1
1
2
0
2
1
0
1
1
1
1
1
0
2
2
2
1
0
1
0
...

output:

0 759 146 948 401 726 444 435 624 864 291 692 297 446 754 4 146 460 612 463 615 231 449 896 468 248 173 268 130 352 406 181 932 376 693 275 163 162 768 949 368 269 292 156 828 55 325 755 913 976 385 48 614 619 175 73 273 816 642 927 482 832 389 375 719 216 859 404 361 151 344 221 104 267 636 75 435 ...

result:

ok Accepted

Test #27:

score: 0
Accepted
time: 225ms
memory: 3596kb

input:

985
1
1
1
2
1
2
0
1
0
0
1
1
0
0
1
1
1
0
1
0
1
1
1
1
0
2
2
1
1
1
1
0
0
1
1
2
2
0
1
0
1
1
1
1
1
0
1
1
1
0
1
1
0
0
0
1
0
1
0
1
1
2
0
1
0
1
1
1
0
0
1
1
2
1
1
0
1
0
2
0
0
0
0
1
0
1
1
0
0
1
0
0
2
0
1
0
0
1
1
1
0
1
0
1
1
1
0
2
0
1
0
1
1
1
0
2
1
0
1
1
0
0
1
1
0
1
1
1
0
0
1
0
0
1
0
2
0
1
0
0
1
1
1
1
1
1
1
1
...

output:

0 140 363 750 846 798 343 504 746 871 903 563 564 904 228 580 120 790 712 834 520 210 14 439 166 467 16 939 720 285 442 864 309 603 702 315 669 469 469 9 511 38 536 378 626 201 813 974 649 906 313 762 543 181 606 662 942 163 555 853 183 930 308 699 202 487 694 582 257 820 478 274 940 613 953 813 192...

result:

ok Accepted

Test #28:

score: 0
Accepted
time: 238ms
memory: 3668kb

input:

986
0
2
0
2
0
2
1
0
1
0
2
2
2
0
1
0
2
0
0
0
0
2
2
2
1
1
1
0
2
1
1
2
0
1
1
1
1
0
1
0
0
2
0
1
1
1
1
2
1
1
2
0
0
1
1
1
1
0
1
1
1
1
2
2
0
0
2
2
2
1
1
1
1
1
1
2
1
0
0
2
2
0
1
1
0
2
2
2
1
1
2
1
0
1
0
0
1
1
2
1
1
0
1
0
1
1
0
2
1
1
2
1
1
1
0
2
1
1
2
1
0
2
2
0
0
2
1
0
0
1
1
1
1
1
1
0
1
0
2
0
1
0
1
0
1
1
1
0
...

output:

0 173 480 926 809 533 646 303 415 325 732 125 754 517 24 380 925 975 904 50 250 946 951 201 921 209 136 158 23 313 384 535 897 957 112 782 830 324 688 377 355 824 28 553 117 306 880 77 438 135 382 398 811 745 307 912 792 805 510 903 961 830 406 466 154 846 757 606 837 21 862 807 554 613 359 333 339 ...

result:

ok Accepted

Test #29:

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

input:

987
0
1
0
1
1
1
1
1
1
1
1
2
2
2
0
0
2
1
0
1
0
0
1
0
1
0
1
1
2
1
1
1
1
2
0
0
1
1
0
2
2
1
1
1
0
0
1
1
0
2
1
1
0
0
2
0
0
0
1
1
0
1
0
2
2
0
1
0
2
2
1
1
2
2
2
1
0
0
1
0
1
1
1
1
2
1
1
1
1
0
0
0
1
0
1
1
0
1
0
1
1
2
1
1
1
1
2
0
0
0
1
1
1
1
2
1
1
1
1
1
1
1
0
0
1
1
0
0
2
2
2
1
0
1
1
2
1
0
2
0
1
1
0
1
1
1
1
1
...

output:

0 137 676 30 217 980 729 918 832 839 156 179 38 494 334 787 400 137 745 974 61 621 125 356 389 827 390 317 672 483 282 7 64 265 236 525 38 273 512 353 468 205 268 91 906 745 668 483 60 579 507 650 378 350 982 151 263 852 32 572 328 803 226 887 717 380 488 888 87 685 797 517 797 762 282 668 607 831 9...

result:

ok Accepted

Test #30:

score: 0
Accepted
time: 254ms
memory: 3832kb

input:

988
0
1
0
0
1
0
0
0
1
0
1
1
0
2
2
1
1
2
0
1
1
2
1
1
1
1
0
1
1
2
1
0
2
1
1
0
0
1
0
1
0
1
1
1
0
0
1
1
1
0
1
0
1
0
1
0
2
2
1
0
1
0
1
0
1
1
2
0
1
1
1
0
0
1
1
0
1
1
1
0
0
2
1
0
1
0
1
1
2
2
0
0
0
1
0
1
1
1
0
1
1
2
1
1
2
2
1
0
1
1
1
0
2
1
1
1
1
1
1
0
2
1
0
2
1
1
1
0
1
1
1
0
0
1
0
2
0
2
2
2
0
0
0
2
0
1
0
2
...

output:

0 599 227 687 505 100 190 961 475 910 387 724 881 562 118 703 788 924 744 17 522 571 194 761 975 745 513 434 569 895 111 373 379 89 520 129 671 563 350 324 150 741 337 88 783 614 916 328 683 746 727 857 692 798 956 465 941 661 298 578 941 165 547 383 522 583 677 519 801 669 783 721 228 270 150 697 5...

result:

ok Accepted

Test #31:

score: 0
Accepted
time: 249ms
memory: 3648kb

input:

989
1
3
0
1
1
0
2
0
1
1
0
0
2
0
1
0
2
1
1
1
1
1
1
0
0
1
0
0
1
1
0
1
1
1
0
0
1
0
1
1
0
1
1
2
2
0
1
1
0
2
2
1
0
1
0
1
1
1
1
1
1
1
0
1
1
0
1
0
1
1
2
1
0
0
0
0
1
0
1
0
0
2
1
0
1
1
2
1
0
2
1
1
0
2
0
0
1
0
2
1
0
1
0
0
1
1
1
0
1
0
1
0
0
1
1
1
0
1
0
0
1
1
0
2
1
1
0
1
1
0
2
0
2
1
0
2
1
1
2
0
1
0
0
2
0
1
0
0
...

output:

0 555 186 175 195 788 816 281 528 879 704 248 171 396 910 957 27 29 423 281 898 181 350 537 764 761 492 346 237 77 49 127 720 14 775 151 722 603 361 709 742 351 280 338 888 647 932 208 818 908 876 570 739 546 51 64 235 172 308 839 227 489 370 782 840 738 900 703 451 592 912 985 428 887 433 257 163 4...

result:

ok Accepted

Test #32:

score: 0
Accepted
time: 240ms
memory: 3592kb

input:

990
1
0
2
0
2
1
1
0
2
2
1
0
2
2
0
0
1
1
2
1
1
0
1
1
1
1
2
1
1
1
0
0
0
1
0
1
1
0
2
1
0
2
1
0
1
0
0
1
0
2
1
1
1
1
2
2
0
0
2
2
0
2
1
0
1
1
1
1
0
0
2
2
0
0
1
0
2
2
1
0
2
1
0
1
1
1
0
1
1
1
1
1
0
1
0
1
1
1
1
2
1
1
1
1
1
1
1
1
0
1
0
0
1
1
1
0
0
2
1
0
1
1
1
0
1
1
1
1
1
0
2
0
2
0
2
1
1
2
1
0
0
0
2
0
2
1
0
0
...

output:

0 719 829 606 70 191 605 888 164 832 855 477 390 952 76 906 588 671 463 899 558 461 976 625 633 356 794 925 952 17 817 895 9 755 696 347 480 292 149 403 508 915 200 110 361 784 930 60 454 177 523 968 189 92 866 699 22 990 108 452 791 519 402 810 459 248 431 921 39 459 261 198 576 6 702 247 36 607 39...

result:

ok Accepted

Test #33:

score: 0
Accepted
time: 246ms
memory: 3696kb

input:

991
0
0
0
0
2
2
1
1
2
2
1
1
1
1
0
1
0
1
0
1
1
2
2
1
0
0
1
0
1
1
0
1
1
2
1
0
1
0
0
1
0
1
0
2
0
1
0
1
0
2
1
0
1
1
1
1
0
1
1
0
0
1
0
1
1
1
1
2
1
0
1
0
1
0
2
1
1
1
0
1
1
0
0
0
1
0
1
1
0
1
0
1
1
1
1
1
1
1
0
1
0
0
0
0
1
0
0
0
2
2
1
0
1
1
2
0
1
0
1
1
0
2
2
1
0
0
0
0
0
1
0
0
0
0
1
0
0
1
1
1
0
0
1
1
2
1
0
0
...

output:

0 101 548 118 956 239 138 918 583 649 958 988 986 618 439 990 427 360 14 345 560 768 274 33 973 972 983 7 269 831 514 493 58 755 685 62 909 761 457 297 745 541 379 275 454 293 388 600 745 395 964 981 335 896 848 102 168 861 466 101 413 974 575 460 345 726 42 372 251 950 231 396 898 949 899 218 553 3...

result:

ok Accepted

Test #34:

score: 0
Accepted
time: 260ms
memory: 3656kb

input:

992
2
0
1
1
0
2
0
0
2
2
0
0
2
2
2
1
1
2
0
1
0
0
0
0
1
0
0
1
0
2
0
2
2
2
1
0
1
1
2
0
1
1
1
0
1
0
1
1
1
0
1
0
1
0
2
1
0
1
1
1
0
2
1
0
1
0
1
1
1
0
0
2
1
0
0
0
2
1
0
2
1
1
1
1
1
0
0
1
0
1
1
2
1
0
1
1
2
0
2
1
0
1
1
0
2
1
1
1
1
1
0
0
1
0
1
1
1
0
1
1
2
2
2
2
1
0
0
0
0
1
0
0
1
0
2
1
0
0
1
0
0
1
1
2
1
0
0
2
...

output:

0 964 233 505 918 84 83 811 31 632 384 186 793 173 529 331 115 38 528 912 649 922 285 214 43 472 510 531 523 607 275 895 441 556 308 664 34 1 682 213 398 966 939 562 674 798 798 237 382 55 198 753 151 952 463 46 637 466 942 899 68 443 655 733 235 796 164 992 787 846 440 28 336 985 894 494 378 71 679...

result:

ok Accepted

Test #35:

score: 0
Accepted
time: 247ms
memory: 3544kb

input:

993
2
1
3
1
0
1
1
2
2
2
1
1
1
1
1
1
1
0
1
0
1
1
2
0
1
0
0
0
2
0
1
1
1
1
0
1
1
1
0
1
0
1
0
1
1
1
1
2
1
0
1
1
1
1
0
1
1
2
1
1
0
0
1
1
2
0
1
1
2
0
1
0
0
2
0
1
0
1
0
2
0
1
1
0
2
0
1
1
1
0
1
1
0
1
1
0
1
1
0
0
0
2
1
1
1
0
2
1
0
2
0
1
0
1
0
0
1
1
1
1
1
1
1
0
1
1
1
0
1
1
1
0
2
2
1
1
0
1
0
2
1
1
1
1
1
1
0
0
...

output:

0 285 515 593 455 692 454 346 814 570 111 611 319 128 987 526 191 557 685 451 834 68 93 986 96 451 393 426 174 438 236 46 685 760 316 100 744 145 535 339 399 484 690 677 399 905 530 713 57 900 73 520 66 600 738 352 501 918 345 642 394 654 289 695 823 990 929 550 821 620 137 456 20 45 553 109 345 355...

result:

ok Accepted

Test #36:

score: 0
Accepted
time: 281ms
memory: 3600kb

input:

994
1
0
1
1
0
2
1
1
1
1
2
2
1
1
1
0
2
1
1
0
1
0
2
0
1
0
2
0
2
2
0
2
1
1
0
0
0
1
1
1
0
1
0
0
2
1
0
0
1
1
1
1
1
0
2
2
2
1
1
0
0
1
1
1
1
2
1
0
1
0
2
2
2
1
1
1
1
1
0
1
0
0
1
0
1
1
1
0
0
0
1
0
1
1
1
0
1
1
1
1
2
1
0
0
2
1
0
2
2
2
0
0
2
2
2
0
1
0
0
2
2
2
1
1
1
0
1
1
1
0
0
0
1
0
2
2
2
2
1
0
1
1
1
0
0
0
1
0
...

output:

0 247 249 169 573 178 374 56 500 71 410 734 428 76 662 782 577 965 158 605 179 472 152 975 569 760 246 592 369 897 40 326 686 490 906 585 13 847 325 382 260 227 356 653 948 873 517 554 151 814 45 37 730 492 302 509 479 983 52 896 780 379 717 896 100 949 156 283 137 661 243 546 527 834 652 48 691 253...

result:

ok Accepted

Test #37:

score: 0
Accepted
time: 264ms
memory: 3856kb

input:

995
3
0
0
1
0
1
0
2
0
2
1
1
2
0
0
0
0
1
0
2
1
0
0
1
0
0
0
1
0
1
0
1
1
1
0
0
1
1
1
1
2
0
2
0
2
0
2
1
0
0
2
2
1
0
2
2
2
2
2
2
1
1
1
1
1
1
0
1
0
1
1
1
0
0
1
1
2
1
1
0
2
2
0
1
0
1
1
0
2
2
1
0
1
0
1
1
1
1
1
1
2
1
1
1
1
1
0
0
1
0
1
0
1
0
1
0
2
0
1
1
2
0
1
1
1
0
2
2
2
1
1
1
1
1
1
1
1
2
1
1
1
1
0
2
2
1
0
0
...

output:

0 260 316 826 131 584 390 281 877 46 972 986 689 526 368 340 613 39 338 498 833 804 300 234 764 559 738 258 854 940 471 103 46 68 353 247 279 338 488 699 992 899 970 309 92 370 902 179 303 365 136 921 759 641 13 936 147 172 604 442 86 234 165 110 10 869 836 498 383 531 527 752 108 457 81 238 975 588...

result:

ok Accepted

Test #38:

score: 0
Accepted
time: 248ms
memory: 3660kb

input:

996
2
1
1
4
0
1
0
2
1
1
1
1
1
1
0
0
2
2
0
2
1
0
2
1
0
0
2
0
2
2
0
0
0
1
0
0
2
2
1
0
1
0
0
1
1
1
1
0
1
0
0
2
2
0
0
2
1
1
1
1
0
1
0
0
1
0
1
0
1
1
0
1
1
0
2
2
0
0
2
2
1
1
2
0
2
0
2
1
1
1
1
0
1
1
1
0
2
1
0
2
0
2
2
1
1
2
2
1
0
1
0
1
1
1
1
2
1
1
1
0
2
2
0
0
1
0
2
1
0
2
1
1
2
1
1
1
1
0
1
0
2
1
0
0
1
0
1
1
...

output:

0 441 664 243 341 496 435 462 288 860 54 565 281 643 61 940 697 73 581 640 822 952 476 498 689 974 611 606 744 587 639 843 901 245 319 414 116 366 300 713 836 773 765 555 737 305 572 213 3 149 364 686 30 81 564 465 70 755 142 559 695 696 230 961 785 524 417 753 801 525 422 446 865 814 73 838 32 56 2...

result:

ok Accepted

Test #39:

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

input:

997
0
0
0
1
0
1
1
0
1
0
0
0
2
2
1
1
1
1
0
2
1
0
0
0
1
1
2
1
0
0
1
1
2
0
2
1
1
1
0
1
1
2
2
1
0
0
1
1
0
1
1
0
1
0
0
0
1
0
2
0
1
1
1
0
1
1
1
0
2
1
0
1
0
2
0
0
1
1
1
0
0
1
1
0
1
1
1
1
0
0
2
1
1
1
0
2
2
1
1
1
0
2
1
1
2
1
0
1
0
2
2
1
0
0
1
0
0
1
1
2
0
2
1
1
1
1
1
1
1
1
0
1
1
2
2
0
1
0
1
0
0
1
0
1
1
1
1
0
...

output:

0 487 956 261 482 456 848 916 55 938 363 426 807 179 890 606 69 679 297 989 893 346 384 606 286 158 741 777 852 361 499 852 357 821 594 88 409 182 271 640 303 987 687 79 990 578 367 390 298 843 840 127 274 210 849 639 6 600 995 817 336 236 184 935 585 938 431 96 56 576 352 491 769 653 966 989 268 95...

result:

ok Accepted

Test #40:

score: 0
Accepted
time: 248ms
memory: 3664kb

input:

998
0
2
1
0
1
1
1
1
1
0
1
0
0
2
1
0
2
2
1
0
0
0
2
0
1
1
1
1
1
1
2
0
0
1
0
2
2
0
1
0
1
0
2
0
1
0
2
1
1
1
0
0
0
1
0
0
0
0
2
0
1
1
2
0
1
0
2
1
0
2
2
2
1
1
1
1
0
0
1
1
0
1
1
2
0
1
1
1
0
1
1
1
1
2
0
1
0
2
2
1
0
2
2
2
2
1
0
1
0
1
0
1
0
2
2
1
0
1
1
1
0
1
0
1
1
0
2
2
0
2
0
1
1
1
1
1
1
1
1
0
2
1
0
1
1
2
1
0
...

output:

0 427 314 965 190 8 515 569 542 37 803 608 515 105 559 376 780 968 801 776 215 969 616 668 175 1 212 660 29 925 928 701 743 734 797 9 18 630 837 666 377 754 897 474 445 114 225 818 698 995 716 554 3 64 59 30 778 840 75 499 653 381 791 301 240 177 578 619 287 468 35 931 98 915 142 30 976 649 872 205 ...

result:

ok Accepted

Test #41:

score: 0
Accepted
time: 249ms
memory: 3656kb

input:

999
1
1
1
3
0
1
0
1
0
1
1
1
0
2
0
1
1
1
1
1
1
0
1
0
0
2
0
1
0
1
0
1
0
2
1
1
2
1
1
2
0
1
1
0
0
1
1
2
0
2
1
0
2
1
0
1
0
2
1
1
1
1
1
1
0
1
0
0
1
0
1
0
2
1
0
1
1
1
0
1
1
1
0
1
0
0
1
1
0
2
1
1
0
1
1
1
1
1
0
2
0
0
2
0
1
1
1
1
2
1
1
0
2
2
1
0
1
1
1
0
2
2
2
1
0
1
1
1
1
2
1
1
2
2
0
1
0
0
0
2
1
0
0
0
0
1
0
1
...

output:

0 254 337 717 28 12 726 93 430 194 296 859 594 93 559 623 633 184 848 298 110 533 875 722 741 54 545 821 84 496 240 463 549 817 723 365 688 469 277 444 708 64 118 395 56 953 411 388 889 821 961 405 753 450 742 369 563 568 376 793 212 990 397 273 380 14 866 130 946 668 250 514 288 246 983 878 936 186...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed