QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#601871#9432. PermutationAlliy666AC ✓234ms4176kbC++232.1kb2024-09-30 15:05:262024-09-30 15:05:27

Judging History

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

  • [2024-09-30 15:05:27]
  • 评测
  • 测评结果:AC
  • 用时:234ms
  • 内存:4176kb
  • [2024-09-30 15:05:26]
  • 提交

answer

#include <bits/extc++.h>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937_64 rands(time(0));
int n;
int ans[1005];
int q(int mid,int x,int y)
{
	cout<<"0 ";
	for(int i=1;i<=mid;i++)
		cout<<x<<' ';
	for(int i=mid+1;i<=n;i++)
		cout<<y<<' ';
	cout<<endl;
	int ans;
	cin>>ans;
	return ans;
}
void f(int l,int r,vector<vector<int>> s)
{
	if(l==r)
	{
		ans[l]=s.front().front();
		return;
	}
	shuffle(s.begin(),s.end(),rands);
	vector<vector<int>> ll,rr;
	vector<int> aa;
	aa.push_back(0);
	int mid=l+r>>1;
	map<int,int> mp;
	while(s.size()>1)
	{
		auto x=s.back();
		s.pop_back();
		auto y=s.back();
		s.pop_back();
		int nn= q(mid,x.front(),y.front());
		switch (nn)
		{
			case 0:
				for(auto i:x)
				{
					aa[0]=i;
					rr.push_back(aa);
				}
				for(auto i:y)
				{
					aa[0]=i;
					ll.push_back(aa);
				}
				break;
			case 1:
				if(x.size()<y.size())
					swap(x,y);
				for(auto i:y)
					x.push_back(i);
				s.push_back(x);
				break;
			case 2:
				for(auto i:y)
				{
					aa[0]=i;
					rr.push_back(aa);
				}
				for(auto i:x)
				{
					aa[0]=i;
					ll.push_back(aa);
				}
		}
	}
	if(!s.empty())
	{
		auto x=s.back();
		if(!rr.empty())
		{
			auto y=rr.back();
			int nn=q(mid,x.front(),y.front());
			if(nn==2)
			{
				for(auto i:x)
				{
					aa[0]=i;
					ll.push_back(aa);
				}
			}
			else
			{
				for(auto i:x)
				{
					aa[0]=i;
					rr.push_back(aa);
				}
			}
		}
		else
		{
			auto y=ll.back();
			int nn=q(mid,y.front(),x.front());
			if(nn==2)
			{
				for(auto i:x)
				{
					aa[0]=i;
					rr.push_back(aa);
				}
			}
			else
			{
				for(auto i:x)
				{
					aa[0]=i;
					ll.push_back(aa);
				}
			}
		}
	}
	f(l,mid,ll);
	f(mid+1,r,rr);
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
	cin>>n;
	vector<vector<int>> v;
	vector<int> aa;
	aa.push_back(0);
	for(int i=1;i<=n;i++)
	{
		aa[0]=i;
		v.push_back(aa);
	}
	f(1,n,v);
	cout<<"1 ";
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<' ';
	cout<<endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
1
2
0
0
2
0
2

output:

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

result:

ok Accepted

Test #2:

score: 0
Accepted
time: 224ms
memory: 4148kb

input:

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

output:

0 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 403 40...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1 

result:

ok Accepted

Test #4:

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

input:

2
2

output:

0 2 1 
1 2 1 

result:

ok Accepted

Test #5:

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

input:

3
2
2
0

output:

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

result:

ok Accepted

Test #6:

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

input:

4
0
2
0
0

output:

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

result:

ok Accepted

Test #7:

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

input:

6
2
1
2
1
2
2
2
1
2
0

output:

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

result:

ok Accepted

Test #8:

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

input:

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

output:

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

result:

ok Accepted

Test #9:

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

input:

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

output:

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

result:

ok Accepted

Test #10:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

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

input:

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

output:

0 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 80...

result:

ok Accepted

Test #18:

score: 0
Accepted
time: 207ms
memory: 3880kb

input:

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

output:

0 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 66...

result:

ok Accepted

Test #19:

score: 0
Accepted
time: 212ms
memory: 4144kb

input:

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

output:

0 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 331 33...

result:

ok Accepted

Test #20:

score: 0
Accepted
time: 210ms
memory: 4072kb

input:

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

output:

0 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 620 62...

result:

ok Accepted

Test #21:

score: 0
Accepted
time: 181ms
memory: 4152kb

input:

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

output:

0 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 908 90...

result:

ok Accepted

Test #22:

score: 0
Accepted
time: 196ms
memory: 4148kb

input:

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

output:

0 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 4...

result:

ok Accepted

Test #23:

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

input:

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

output:

0 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 15...

result:

ok Accepted

Test #24:

score: 0
Accepted
time: 196ms
memory: 3920kb

input:

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

output:

0 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 586 58...

result:

ok Accepted

Test #25:

score: 0
Accepted
time: 199ms
memory: 3904kb

input:

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

output:

0 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 12...

result:

ok Accepted

Test #26:

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

input:

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

output:

0 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 55...

result:

ok Accepted

Test #27:

score: 0
Accepted
time: 206ms
memory: 4152kb

input:

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

output:

0 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 91...

result:

ok Accepted

Test #28:

score: 0
Accepted
time: 206ms
memory: 4176kb

input:

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

output:

0 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 3...

result:

ok Accepted

Test #29:

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

input:

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

output:

0 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 89...

result:

ok Accepted

Test #30:

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

input:

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

output:

0 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 362 36...

result:

ok Accepted

Test #31:

score: 0
Accepted
time: 212ms
memory: 3920kb

input:

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

output:

0 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 958 95...

result:

ok Accepted

Test #32:

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

input:

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

output:

0 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 88...

result:

ok Accepted

Test #33:

score: 0
Accepted
time: 194ms
memory: 3924kb

input:

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

output:

0 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 71...

result:

ok Accepted

Test #34:

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

input:

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

output:

0 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 81...

result:

ok Accepted

Test #35:

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

input:

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

output:

0 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 47...

result:

ok Accepted

Test #36:

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

input:

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

output:

0 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 737 73...

result:

ok Accepted

Test #37:

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

input:

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

output:

0 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 460 46...

result:

ok Accepted

Test #38:

score: 0
Accepted
time: 199ms
memory: 3916kb

input:

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

output:

0 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 12...

result:

ok Accepted

Test #39:

score: 0
Accepted
time: 191ms
memory: 3848kb

input:

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

output:

0 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 16...

result:

ok Accepted

Test #40:

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

input:

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

output:

0 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 525 52...

result:

ok Accepted

Test #41:

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

input:

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

output:

0 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 181 18...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed