QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#660759#9432. PermutationLateRegistration#AC ✓274ms4088kbC++202.6kb2024-10-20 13:13:432024-10-20 13:13:44

Judging History

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

  • [2024-10-20 13:13:44]
  • 评测
  • 测评结果:AC
  • 用时:274ms
  • 内存:4088kb
  • [2024-10-20 13:13:43]
  • 提交

answer

#include<bits/stdc++.h>
#define mod 998244353
using namespace std;
inline int read()
{
	int n=0,f=1,ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		n=n*10+ch-'0';
		ch=getchar();
	}
	return n*f;
}
int fa[1005];
int findf(int n)
{
	if(fa[n]==n)return n;
	return fa[n]=findf(fa[n]);
}
int p[1005],q[1005],sc[1005];
int qans[1005];
int sy[1005];
int n;
int qsl=0;
void solve(int l,int r,vector<int>v,int o)
{
	//printf("??%d %d %d\n",l,r,(int)v.size());
	if(l==r)
	{
		sc[l]=v[0];
		return;
	}
	int mid=(l+r)/2,x,y;
	for(int ii=0;ii<v.size();ii++)sy[v[ii]]=0,fa[v[ii]]=v[ii];
	while(1)
	{
		x=0;
		y=0;
		for(int ii=0;ii<v.size();ii++)
		{
			int i=v[ii];
			if(i==fa[i]&&sy[i]==0)
			{
				if(x==0)x=i;
				else if(y==0)y=i;
			}
		}
		//printf("orz %d %d\n",x,y);
		if(x==0||y==0)break;
		for(int i=1;i<=l-1;i++)q[i]=o;
		for(int i=1;i<=mid;i++)q[i]=x;
		for(int i=mid+1;i<=r;i++)q[i]=y;
		for(int i=r+1;i<=n;i++)q[i]=o;
		printf("0 ");
		for(int i=1;i<=n;i++)printf("%d ",q[i]);
		printf("\n");
		fflush(stdout);
		qsl++;
		int ans=read();
		//int ans=0;
		//for(int i=1;i<=n;i++)if(qans[i]==q[i])ans++;
		//printf("!!!%d\n",ans);
		if(ans==1)
		{
			fa[findf(x)]=findf(y);
		}
		else if(ans==0)
		{
			sy[findf(x)]=2;
			sy[findf(y)]=1;
		}
		else sy[findf(x)]=1,sy[findf(y)]=2;
	}
	vector<int>vl,vr;
	for(int ii=0;ii<v.size();ii++)
	{
		if(sy[findf(v[ii])]==1)
		{
			vl.push_back(v[ii]);	
		}
		else if(sy[findf(v[ii])]==2)vr.push_back(v[ii]);
	}
	if(vl.size()<mid-l+1)
	{
		for(int ii=0;ii<v.size();ii++)
		{
			if(sy[findf(v[ii])]==0)
			{
				vl.push_back(v[ii]);	
			}
		}
	}
	else if(vr.size()<r-mid)
	{
		for(int ii=0;ii<v.size();ii++)
		{
			if(sy[findf(v[ii])]==0)
			{
				vr.push_back(v[ii]);	
			}
		}
	}
	//printf("L ");
//	for(int i=0;i<vl.size();i++)printf("%d ",vl[i]);
	//printf("\n");
	//printf("R ");
	//for(int i=0;i<vr.size();i++)printf("%d ",vr[i]);
	//printf("\n");
	solve(l,mid,vl,vl[0]);
	solve(mid+1,r,vr,vr[0]);
}
signed main()
{
	srand((unsigned long long)new char); 
	int x,y;
	n=read();
	for(int i=1;i<=n;i++)p[i]=i;
	for(int i=1;i<=n;i++)swap(p[i],p[rand()%i+1]);
	//for(int i=1;i<=n;i++)qans[i]=i;
	//for(int i=1;i<=n;i++)swap(qans[i],qans[rand()%i+1]);
	for(int i=1;i<=n;i++)sy[i]=0;
	vector<int>v;
	for(int i=1;i<=n;i++)v.push_back(p[i]);
	solve(1,n,v,0);
	printf("1 ");
	for(int i=1;i<=n;i++)printf("%d ",sc[i]);
	printf("\n");
	//printf("%d\n",qsl);
	//for(int i=1;i<=n;i++)assert(sc[i]==qans[i]);
	return 0;
}

详细

Test #1:

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

input:

5
2
2
1
2
0
2

output:

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

result:

ok Accepted

Test #2:

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

input:

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

output:

0 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 417 41...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1 

result:

ok Accepted

Test #4:

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

input:

2
0

output:

0 1 2 
1 2 1 

result:

ok Accepted

Test #5:

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

input:

3
1
2
2

output:

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

result:

ok Accepted

Test #6:

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

input:

4
2
2
0
2

output:

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

result:

ok Accepted

Test #7:

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

input:

6
0
1
2
2
2
2
2

output:

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

result:

ok Accepted

Test #8:

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

input:

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

output:

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

result:

ok Accepted

Test #9:

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

input:

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

output:

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

result:

ok Accepted

Test #10:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

15
1
2
2
1
2
1
2
1
1
0
2
0
2
0
1
0
0
0
1
0
0
0
1
2
0
2
1
0
2
2
0
2

output:

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

result:

ok Accepted

Test #17:

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

input:

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

output:

0 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 795 79...

result:

ok Accepted

Test #18:

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

input:

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

output:

0 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 86...

result:

ok Accepted

Test #19:

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

input:

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

output:

0 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 13...

result:

ok Accepted

Test #20:

score: 0
Accepted
time: 244ms
memory: 3760kb

input:

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

output:

0 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 706 70...

result:

ok Accepted

Test #21:

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

input:

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

output:

0 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 78...

result:

ok Accepted

Test #22:

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

input:

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

output:

0 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 422 42...

result:

ok Accepted

Test #23:

score: 0
Accepted
time: 263ms
memory: 3808kb

input:

981
2
0
1
2
1
2
1
2
1
2
1
2
0
1
2
2
0
0
1
1
0
0
1
2
0
2
0
0
0
0
1
1
2
1
0
1
0
2
2
2
1
1
1
0
1
2
1
0
1
2
1
0
1
2
1
1
1
0
0
1
0
1
1
1
1
2
1
1
1
1
1
1
1
1
1
0
1
1
2
1
2
1
2
1
0
1
1
0
0
1
0
1
1
0
1
1
1
1
1
2
0
1
2
2
2
2
1
0
1
1
0
1
1
1
0
2
1
1
0
1
1
0
0
1
0
2
2
0
2
2
1
2
1
1
1
1
1
1
2
0
1
0
1
2
1
1
0
2
...

output:

0 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 127 12...

result:

ok Accepted

Test #24:

score: 0
Accepted
time: 269ms
memory: 3780kb

input:

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

output:

0 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 231 23...

result:

ok Accepted

Test #25:

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

input:

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

output:

0 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 860 86...

result:

ok Accepted

Test #26:

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

input:

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

output:

0 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 160 16...

result:

ok Accepted

Test #27:

score: 0
Accepted
time: 263ms
memory: 3692kb

input:

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

output:

0 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 17...

result:

ok Accepted

Test #28:

score: 0
Accepted
time: 256ms
memory: 3844kb

input:

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

output:

0 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 31...

result:

ok Accepted

Test #29:

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

input:

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

output:

0 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 7...

result:

ok Accepted

Test #30:

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

input:

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

output:

0 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 3...

result:

ok Accepted

Test #31:

score: 0
Accepted
time: 258ms
memory: 3736kb

input:

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

output:

0 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 4...

result:

ok Accepted

Test #32:

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

input:

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

output:

0 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 497 49...

result:

ok Accepted

Test #33:

score: 0
Accepted
time: 253ms
memory: 3780kb

input:

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

output:

0 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 715 71...

result:

ok Accepted

Test #34:

score: 0
Accepted
time: 274ms
memory: 3740kb

input:

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

output:

0 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 71...

result:

ok Accepted

Test #35:

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

input:

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

output:

0 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 641 64...

result:

ok Accepted

Test #36:

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

input:

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

output:

0 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 443 44...

result:

ok Accepted

Test #37:

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

input:

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

output:

0 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 63...

result:

ok Accepted

Test #38:

score: 0
Accepted
time: 253ms
memory: 4020kb

input:

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

output:

0 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 267 26...

result:

ok Accepted

Test #39:

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

input:

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

output:

0 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 71...

result:

ok Accepted

Test #40:

score: 0
Accepted
time: 241ms
memory: 3764kb

input:

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

output:

0 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 216 21...

result:

ok Accepted

Test #41:

score: 0
Accepted
time: 262ms
memory: 3760kb

input:

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

output:

0 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 503 50...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed