QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#596902#9432. Permutationucup-team4474#AC ✓279ms4256kbC++202.7kb2024-09-28 16:40:322024-09-28 16:40:33

Judging History

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

  • [2024-09-28 16:40:33]
  • 评测
  • 测评结果:AC
  • 用时:279ms
  • 内存:4256kb
  • [2024-09-28 16:40:32]
  • 提交

answer

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<long long,long long>
#define FF fflush(stdout)
#define inf 0x3f3f3f3f
#define endl "\n"
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
//char buf[1<<20],*p1,*p2;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
inline int read()
{
    int s=0,f=1;
    char x=getchar();
    while(!isdigit(x))f=(x=='-'?-1:1),x=getchar();
    while(isdigit(x))s=s*10+x-'0',x=getchar();
    return s*f;
}
#define reaD read
int ans[1005];
int cnt;
int s[1005];
int a[1005];
int p[1005];
int n;
int qy()
{
	for(int i=0;i<=n;i++)
	printf("%d ",s[i]);puts("");FF;
	cnt++; 
	int sum=0;
	for(int i=1;i<=n;i++)
	if(a[i]==s[i])sum++;
//	cout<<sum<<endl;
	return read();
}
int myqy(int a,int b,int l,int r)
{
	int mid=(l+r)>>1;
	for(int i=1;i<l;i++)s[i]=a;
	for(int i=r+1;i<=n;i++)s[i]=a;
	for(int i=l;i<=mid;i++)s[i]=a;
	for(int i=mid+1;i<=r;i++)s[i]=b;
	return qy();
}
void sol(int l,int r,vector<int> d)
{
	if(l==r)
	{
		ans[l]=d[0];
		return ;
	}
	int mid=(l+r)>>1;
	vector<int> ld,rd;
	random_shuffle(d.begin(),d.end());
	vector<pair<vector<int>,vector<int> > > tmp;
	vector<vector<int> > lef;
	for(int i=0;i+1<d.size();i+=2)
	{
		vector<int> a(1,d[i]),b(1,d[i+1]);
		tmp.pb(mp(a,b));
	}
	if(d.size()%2)lef.pb(vector<int>(1,d.back()));
	while(tmp.size())
	{
		vector<vector<int> > now;
		for(auto o:tmp)
		{
			vector<int> a=o.fi,b=o.se;
			int v=myqy(a[0],b[0],l,r);
			if(v==0)
			{
				for(auto w:a)
				rd.pb(w);
				for(auto w:b)
				ld.pb(w);
			}
			else if(v==2)
			{
				for(auto w:a)
				ld.pb(w);
				for(auto w:b)
				rd.pb(w);
			}
			else
			{
				for(auto w:b)a.pb(w);
				now.pb(a);
			}
		}
		tmp.clear(); 
		for(int i=0;i+1<now.size();i+=2)
		{
			tmp.pb(mp(now[i],now[i+1]));
		}
		if(now.size()%2)
		lef.pb(now.back());
	}
	reverse(lef.begin(),lef.end());
	for(auto o:lef)
	{
		if(ld.size()+o.size()<=mid-l+1)
		{
			assert(rd.size()+o.size()>r-mid);
			for(auto w:o)ld.pb(w);
		}
		else
		{
			assert(ld.size()+o.size()>mid-l+1);
			for(auto w:o)rd.pb(w);
		}
	}
	sol(l,mid,ld);
	sol(mid+1,r,rd);
}
int main()
{
	srand(time(0));
	n=reaD();
	for(int i=1;i<=n;i++)
	a[i]=i;
	random_shuffle(a+1,a+n+1);
//	cout<<"a: ";
//	for(int i=1;i<=n;i++)
//	cout<<a[i]<<' ';puts("");
	vector<int> d(n);
	for(int i=0;i<n;i++)
	d[i]=i+1;
	sol(1,n,d);
	ans[0]=1;
	bool fl=1;
	for(int i=0;i<=n;i++)
	printf("%d ",ans[i]),fl&=(!i||ans[i]==a[i]);puts("");FF;
//	cout<<"qy: "<<cnt<<endl;
//	if(fl)puts("OK");
//	else puts("WA");
	return 0;
}

详细

Test #1:

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

input:

5
0
2
0
0
0

output:

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

result:

ok Accepted

Test #2:

score: 0
Accepted
time: 272ms
memory: 3992kb

input:

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

output:

0 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 86...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1 

result:

ok Accepted

Test #4:

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

input:

2
0

output:

0 1 2 
1 2 1 

result:

ok Accepted

Test #5:

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

input:

3
2
0

output:

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

result:

ok Accepted

Test #6:

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

input:

4
2
0
2
0

output:

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

result:

ok Accepted

Test #7:

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

input:

6
0
2
0
1
0
0
0

output:

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

result:

ok Accepted

Test #8:

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

input:

7
0
0
1
2
0
2
2
2
0

output:

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

result:

ok Accepted

Test #9:

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

input:

8
2
0
0
0
0
2
2
0
2
0
2
0

output:

0 3 3 3 3 5 5 5 5 
0 4 4 4 4 7 7 7 7 
0 8 8 8 8 1 1 1 1 
0 6 6 6 6 2 2 2 2 
0 2 2 7 7 2 2 2 2 
0 3 3 1 1 3 3 3 3 
0 3 7 3 3 3 3 3 3 
0 1 1 1 2 1 1 1 1 
0 5 5 5 5 5 5 4 4 
0 8 8 8 8 8 8 6 6 
0 6 6 6 6 6 5 6 6 
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: 0ms
memory: 3920kb

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

score: 0
Accepted
time: 237ms
memory: 3824kb

input:

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

output:

0 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 45...

result:

ok Accepted

Test #18:

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

input:

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

output:

0 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 90...

result:

ok Accepted

Test #19:

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

input:

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

output:

0 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 955 95...

result:

ok Accepted

Test #20:

score: 0
Accepted
time: 268ms
memory: 4252kb

input:

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

output:

0 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 11...

result:

ok Accepted

Test #21:

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

input:

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

output:

0 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 298 29...

result:

ok Accepted

Test #22:

score: 0
Accepted
time: 230ms
memory: 3972kb

input:

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

output:

0 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 86...

result:

ok Accepted

Test #23:

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

input:

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

output:

0 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 769 76...

result:

ok Accepted

Test #24:

score: 0
Accepted
time: 266ms
memory: 3908kb

input:

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

output:

0 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 168 16...

result:

ok Accepted

Test #25:

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

input:

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

output:

0 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 826 82...

result:

ok Accepted

Test #26:

score: 0
Accepted
time: 259ms
memory: 3908kb

input:

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

output:

0 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 843 84...

result:

ok Accepted

Test #27:

score: 0
Accepted
time: 266ms
memory: 3912kb

input:

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

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 #28:

score: 0
Accepted
time: 279ms
memory: 3888kb

input:

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

output:

0 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 48...

result:

ok Accepted

Test #29:

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

input:

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

output:

0 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 84...

result:

ok Accepted

Test #30:

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

input:

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

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 #31:

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

input:

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

output:

0 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 7...

result:

ok Accepted

Test #32:

score: 0
Accepted
time: 268ms
memory: 3824kb

input:

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

output:

0 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 3...

result:

ok Accepted

Test #33:

score: 0
Accepted
time: 270ms
memory: 4252kb

input:

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

output:

0 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 354 35...

result:

ok Accepted

Test #34:

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

input:

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

output:

0 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 774 77...

result:

ok Accepted

Test #35:

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

input:

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

output:

0 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 509 50...

result:

ok Accepted

Test #36:

score: 0
Accepted
time: 273ms
memory: 3976kb

input:

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

output:

0 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 686 68...

result:

ok Accepted

Test #37:

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

input:

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

output:

0 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 10...

result:

ok Accepted

Test #38:

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

input:

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

output:

0 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 920 92...

result:

ok Accepted

Test #39:

score: 0
Accepted
time: 273ms
memory: 3908kb

input:

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

output:

0 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 936 93...

result:

ok Accepted

Test #40:

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

input:

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

output:

0 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 922 92...

result:

ok Accepted

Test #41:

score: 0
Accepted
time: 278ms
memory: 3968kb

input:

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

output:

0 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 93...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed