QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#742964#9432. PermutationEXODUSAC ✓260ms3808kbC++171.0kb2024-11-13 17:45:362024-11-13 17:45:37

Judging History

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

  • [2024-11-13 17:45:37]
  • 评测
  • 测评结果:AC
  • 用时:260ms
  • 内存:3808kb
  • [2024-11-13 17:45:36]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

mt19937 rnd(time(0));

constexpr int N=1005;

int n,a[N],b[N],ans[N];

int query(int l,int r,int x,int y){
	int mid=(l+r)>>1,res=0;
	cout<<0<<' ';
	for(int i=1;i<=n;i++)
		cout<<(i>mid&&i<=r?y:x)<<' ';
	cout<<endl;
	cin>>res;
	return res;
}

void solve(int l,int r){
	if(l==r)return;
	int mid=(l+r)>>1;
	for (int i=l,j=l,k=mid+1;i<=r;i++){
		if(j>mid){
			b[k++]=a[i];
			continue;
		}else if(k>r){
			b[j++]=a[i];
			continue;
		}
		for(int t=i+1;t<=r;t++){
			int res=query(l,r,a[i],a[t]);
			if(res==2){
				for(int p=i;p<t;p++)b[j++]=a[p];
				b[k++]=a[t];i=t;
				break;
			}else if(res==0){
				for(int p=i;p<t;p++)b[k++]=a[p];
				b[j++]=a[t];i=t;
				break;
			}
		}
	}
	for(int i=l;i<=r;i++)a[i]=b[i];
	solve(l,mid);solve(mid+1,r);
}

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		a[i]=i;
	}
	shuffle(a+1,a+n+1,rnd);
	solve(1,n);
	cout<<1<<' ';
	for (int i=1;i<=n;i++)cout<<a[i]<<' ';
	cout<<endl;
	return 0;
}

詳細信息

Test #1:

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

input:

5
1
2
0
1
2
0
2

output:

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

input:

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

output:

0 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 409 40...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1 

result:

ok Accepted

Test #4:

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

input:

2
2

output:

0 2 1 
1 2 1 

result:

ok Accepted

Test #5:

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

input:

3
0
0

output:

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

result:

ok Accepted

Test #6:

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

input:

4
2
0
0
0

output:

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

result:

ok Accepted

Test #7:

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

input:

6
2
1
2
2
0
1
2
0

output:

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

input:

7
1
0
2
1
2
2
0
1
2
0

output:

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

input:

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

output:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

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

input:

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

output:

0 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 421 42...

result:

ok Accepted

Test #18:

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

input:

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

output:

0 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 765 76...

result:

ok Accepted

Test #19:

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

input:

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

output:

0 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 12...

result:

ok Accepted

Test #20:

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

input:

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

output:

0 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 87...

result:

ok Accepted

Test #21:

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

input:

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

output:

0 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 40...

result:

ok Accepted

Test #22:

score: 0
Accepted
time: 214ms
memory: 3672kb

input:

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

output:

0 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 180 18...

result:

ok Accepted

Test #23:

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

input:

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

output:

0 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 823 82...

result:

ok Accepted

Test #24:

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

input:

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

output:

0 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 576 57...

result:

ok Accepted

Test #25:

score: 0
Accepted
time: 214ms
memory: 3620kb

input:

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

output:

0 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 392 39...

result:

ok Accepted

Test #26:

score: 0
Accepted
time: 204ms
memory: 3768kb

input:

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

output:

0 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 15...

result:

ok Accepted

Test #27:

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

input:

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

output:

0 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 402 40...

result:

ok Accepted

Test #28:

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

input:

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

output:

0 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 26...

result:

ok Accepted

Test #29:

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

input:

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

output:

0 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 692 69...

result:

ok Accepted

Test #30:

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

input:

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

output:

0 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 165 16...

result:

ok Accepted

Test #31:

score: 0
Accepted
time: 220ms
memory: 3676kb

input:

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

output:

0 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 45...

result:

ok Accepted

Test #32:

score: 0
Accepted
time: 219ms
memory: 3672kb

input:

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

output:

0 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 86...

result:

ok Accepted

Test #33:

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

input:

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

output:

0 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 58...

result:

ok Accepted

Test #34:

score: 0
Accepted
time: 218ms
memory: 3680kb

input:

992
1
1
0
0
1
1
0
1
2
2
1
2
2
0
0
1
1
1
1
1
1
0
0
1
0
2
0
2
2
1
2
0
1
0
0
1
1
2
0
0
0
1
2
1
2
0
1
1
1
0
0
1
0
1
1
2
1
1
1
1
1
1
2
1
1
1
0
0
1
1
2
1
2
0
2
2
1
0
1
1
1
1
1
1
2
1
1
1
1
1
1
1
0
1
2
0
2
0
2
0
0
2
1
1
2
0
2
1
1
1
1
2
0
2
1
1
1
1
1
2
0
1
2
1
0
0
2
2
0
2
2
2
0
0
0
2
0
2
1
1
0
2
0
1
2
1
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 #35:

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

input:

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

output:

0 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 700 70...

result:

ok Accepted

Test #36:

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

input:

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

output:

0 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 418 41...

result:

ok Accepted

Test #37:

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

input:

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

output:

0 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 85...

result:

ok Accepted

Test #38:

score: 0
Accepted
time: 205ms
memory: 3680kb

input:

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

output:

0 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 11...

result:

ok Accepted

Test #39:

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

input:

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

output:

0 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 281 28...

result:

ok Accepted

Test #40:

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

input:

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

output:

0 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 861 86...

result:

ok Accepted

Test #41:

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

input:

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

output:

0 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 352 35...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed