QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#745720#9432. PermutationhotdogsellerAC ✓285ms4132kbC++141.9kb2024-11-14 11:13:312024-11-14 11:13:33

Judging History

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

  • [2024-11-14 11:13:33]
  • 评测
  • 测评结果:AC
  • 用时:285ms
  • 内存:4132kb
  • [2024-11-14 11:13:31]
  • 提交

answer

#include<bits/stdc++.h>

#define maxn 1005
#define INF 1e18
//#define int long long

using namespace std;

inline int read(){
	int lre=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-'){
			f=-1;
		}
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		lre=(lre<<3)+(lre<<1)+(c-'0');
		c=getchar();
	}
	return lre*f;
}

int n;
int arr[maxn];

int query(int l,int r,int x,int y){
	printf("0 ");
	int mid=l+r>>1;
	for(int i=1;i<=mid;++i){
		printf("%lld ",x);
	} 
	for(int j=mid+1;j<=n;j++){
		printf("%lld ",y);
	}
	putchar('\n');
	fflush(stdout);
	return read();
}

void print(){
	printf("1 ");
	for(int i=1;i<=n;++i){
		printf("%lld ",arr[i]);
	} 
	putchar('\n');
	fflush(stdout);
}

void dfs(int l,int r,vector<int> v){
	if(l==r){
		arr[l]=v[0];
		return;//递归边界 
	} 
	int mid=l+r>>1;
	vector<int> a,b;//左,右节点
	random_shuffle(v.begin(),v.end());
	
	int i=0,lst=0;
	while(i+1<v.size()){
		int lre=query(l,r,v[i],v[i+1]);
		if(lre==0){
			//v[i+1]在左,v[i]在右
			a.push_back(v[i+1]);
		//	cout<<v[i+1]<<" to left!"<<endl;
			b.push_back(v[i]);
		//	cout<<v[i]<<" to right!"<<endl;
			for(int j=lst;j<i;j++){
				b.push_back(v[j]);
			}
			lst=i+2;
			i+=2; 
		}else if(lre==2){
			a.push_back(v[i]);
			b.push_back(v[i+1]); 
			for(int j=lst;j<i;j++){
				a.push_back(v[j]);
			}
			lst=i+2;
			i+=2; 
		}else{
			//lre=1说明v[i]和v[i+1]在同侧 
			i++; 
		}
	} 
	if(a.size()<mid-l+1){
		//向左填
		for(int i=lst;i<v.size();++i){
			a.push_back(v[i]);
		} 
	}else{
		//向右填 
		for(int i=lst;i<v.size();++i){
			b.push_back(v[i]);
		} 
	}
	
	dfs(l,mid,a);
	dfs(mid+1,r,b); 
}//左,右,可能存在节点 

signed main(){
	
	srand(time(0));
	
	n=read();
	vector<int> v0;
	for(int i=1;i<=n;i++){
		v0.push_back(i);
	} 
	dfs(1,n,v0);
	print();
	
	return 0;
} 
/*
4


*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
1
2
2
1
2
0
0

output:

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

result:

ok Accepted

Test #2:

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

input:

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

output:

0 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 87...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1 

result:

ok Accepted

Test #4:

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

input:

2
2

output:

0 2 1 
1 2 1 

result:

ok Accepted

Test #5:

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

input:

3
0
0

output:

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

result:

ok Accepted

Test #6:

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

input:

4
0
2
0
2

output:

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

result:

ok Accepted

Test #7:

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

input:

6
2
2
2
1
2
0
2
0

output:

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

result:

ok Accepted

Test #8:

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

input:

7
2
2
0
1
2
2
2
2
2

output:

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

input:

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

output:

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

result:

ok Accepted

Test #10:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

0 10 10 10 10 10 10 10 10 11 11 11 11 11 11 11 
0 11 11 11 11 11 11 11 11 15 15 15 15 15 15 15 
0 15 15 15 15 15 15 15 15 8 8 8 8 8 8 8 
0 4 4 4 4 4 4 4 4 1 1 1 1 1 1 1 
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 12 12 12 12 12 12 12 
0 2 2 2 2 2 2 2 2 5 5 5 5 5 5 5 
0 5 5 5 5...

result:

ok Accepted

Test #17:

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

input:

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

output:

0 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 24...

result:

ok Accepted

Test #18:

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

input:

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

output:

0 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 21...

result:

ok Accepted

Test #19:

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

input:

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

output:

0 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 296 29...

result:

ok Accepted

Test #20:

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

input:

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

output:

0 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 27...

result:

ok Accepted

Test #21:

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

input:

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

output:

0 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 20...

result:

ok Accepted

Test #22:

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

input:

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

output:

0 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 59...

result:

ok Accepted

Test #23:

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

input:

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

output:

0 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 709 70...

result:

ok Accepted

Test #24:

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

input:

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

output:

0 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 14...

result:

ok Accepted

Test #25:

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

input:

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

output:

0 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 815 81...

result:

ok Accepted

Test #26:

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

input:

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

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

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

input:

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

output:

0 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 725 72...

result:

ok Accepted

Test #28:

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

input:

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

output:

0 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 87...

result:

ok Accepted

Test #29:

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

input:

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

output:

0 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 61...

result:

ok Accepted

Test #30:

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

input:

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

output:

0 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 18...

result:

ok Accepted

Test #31:

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

input:

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

output:

0 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 51...

result:

ok Accepted

Test #32:

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

input:

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

output:

0 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 10...

result:

ok Accepted

Test #33:

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

input:

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

output:

0 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 1...

result:

ok Accepted

Test #34:

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

input:

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

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

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

input:

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

output:

0 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 88...

result:

ok Accepted

Test #36:

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

input:

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

output:

0 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 481 48...

result:

ok Accepted

Test #37:

score: 0
Accepted
time: 277ms
memory: 3876kb

input:

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

output:

0 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 74...

result:

ok Accepted

Test #38:

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

input:

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

output:

0 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 14...

result:

ok Accepted

Test #39:

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

input:

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

output:

0 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 851 85...

result:

ok Accepted

Test #40:

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

input:

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

output:

0 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 1...

result:

ok Accepted

Test #41:

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

input:

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

output:

0 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 394 39...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed