QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#742178#9432. Permutationzero-rangeAC ✓271ms1732kbC++231.4kb2024-11-13 16:02:052024-11-13 16:02:08

Judging History

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

  • [2024-11-13 16:02:08]
  • 评测
  • 测评结果:AC
  • 用时:271ms
  • 内存:1732kb
  • [2024-11-13 16:02:05]
  • 提交

answer

#include<stdio.h>
#include<vector>
#include<random>
#include<time.h>
#include<algorithm>
#include<string.h>
#define M 1005
using namespace std;
int n,a[M],b[M],bt,st[M],tp,f[M];
mt19937_64 rnd(time(0));
int find(int x){return x!=f[x]?(f[x]=find(f[x])):x;}
void sol(int l,int r){
	if(l>=r) return;
	int mid=l+r>>1;bt=0;
	for(int i=l;i<=r;++i) b[++bt]=a[i];
	shuffle(b+1,b+bt+1,rnd);
	tp=bt,memcpy(st,b,(tp+1)<<2);
	for(int i=1;i<=bt;++i) f[b[i]]=b[i];
	int cl=l,cr=mid+1;
	while(tp>1){
		int x=st[tp--],y=st[tp--];
		printf("0 ");
		for(int i=1;i<=mid;++i) printf("%d ",x);
		for(int i=mid+1;i<=n;++i) printf("%d ",y);
		puts(""),fflush(stdout);
		int v;scanf("%d",&v);
		if(v==2){
			for(int i=1;i<=bt;++i) if(find(b[i])==x) a[cl++]=b[i];
			for(int i=1;i<=bt;++i) if(find(b[i])==y) a[cr++]=b[i];
		}else if(v==0){
			for(int i=1;i<=bt;++i) if(find(b[i])==x) a[cr++]=b[i];
			for(int i=1;i<=bt;++i) if(find(b[i])==y) a[cl++]=b[i];
		}else st[++tp]=x,f[find(y)]=x;
	}
	if(tp){
		int x=st[tp];
		for(int i=1;i<=bt;++i) if(find(b[i])==x){
			if(cl<=mid) a[cl++]=b[i];
			else a[cr++]=b[i];
		}
	}
	// printf("[%d, %d]: %d %d %d\n",l,r,mid,cl,cr);
	// for(int i=l;i<=r;++i) printf("%d ",a[i]);
	// puts("");
	sol(l,mid),sol(mid+1,r);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i) a[i]=i;
	sol(1,n);
	printf("1 ");
	for(int i=1;i<=n;++i) printf("%d ",a[i]);
}

詳細信息

Test #1:

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

input:

5
0
0
0
2
2

output:

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

result:

ok Accepted

Test #2:

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

input:

1000
0
1
2
0
1
1
0
1
1
1
2
0
0
1
2
2
1
1
0
0
1
1
1
1
2
1
0
2
2
0
1
1
0
1
0
1
2
1
1
2
1
1
0
1
0
1
1
1
1
1
1
1
0
1
1
1
1
1
0
1
1
1
1
0
1
1
1
1
2
0
0
1
2
1
2
0
2
2
0
0
1
1
2
1
1
0
2
1
0
1
2
1
0
1
0
2
0
0
1
1
1
1
0
0
2
0
1
0
0
1
1
2
1
0
2
2
1
1
2
2
1
1
1
2
0
1
1
2
1
0
0
2
2
0
2
2
2
1
1
1
0
1
1
0
0
1
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 #3:

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

input:

1

output:

1 1 

result:

ok Accepted

Test #4:

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

input:

2
0

output:

0 1 2 
1 2 1 

result:

ok Accepted

Test #5:

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

input:

3
1
2
2

output:

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

result:

ok Accepted

Test #6:

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

input:

4
1
0
0
0

output:

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

result:

ok Accepted

Test #7:

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

input:

6
0
0
0
2
2
2
2

output:

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

result:

ok Accepted

Test #8:

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

input:

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

output:

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

input:

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

output:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

10
2
0
0
2
0
0
2
2
0
0
2
0
2
0
2

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

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

input:

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

output:

0 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 775 77...

result:

ok Accepted

Test #18:

score: 0
Accepted
time: 208ms
memory: 1732kb

input:

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

output:

0 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 94...

result:

ok Accepted

Test #19:

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

input:

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

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

score: 0
Accepted
time: 235ms
memory: 1692kb

input:

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

output:

0 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 432 43...

result:

ok Accepted

Test #21:

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

input:

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

output:

0 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 731 73...

result:

ok Accepted

Test #22:

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

input:

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

output:

0 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 7...

result:

ok Accepted

Test #23:

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

input:

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

output:

0 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 11...

result:

ok Accepted

Test #24:

score: 0
Accepted
time: 227ms
memory: 1720kb

input:

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

output:

0 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 545 54...

result:

ok Accepted

Test #25:

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

input:

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

output:

0 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 4...

result:

ok Accepted

Test #26:

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

input:

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

output:

0 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 7...

result:

ok Accepted

Test #27:

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

input:

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

output:

0 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 36...

result:

ok Accepted

Test #28:

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

input:

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

output:

0 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 621 62...

result:

ok Accepted

Test #29:

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

input:

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

output:

0 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 25...

result:

ok Accepted

Test #30:

score: 0
Accepted
time: 232ms
memory: 1704kb

input:

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

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

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

input:

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

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

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

input:

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

output:

0 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 72...

result:

ok Accepted

Test #33:

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

input:

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

output:

0 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 89...

result:

ok Accepted

Test #34:

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

input:

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

output:

0 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 178 17...

result:

ok Accepted

Test #35:

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

input:

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

output:

0 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 38...

result:

ok Accepted

Test #36:

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

input:

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

output:

0 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 95...

result:

ok Accepted

Test #37:

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

input:

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

output:

0 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 330 33...

result:

ok Accepted

Test #38:

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

input:

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

output:

0 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 398 39...

result:

ok Accepted

Test #39:

score: 0
Accepted
time: 271ms
memory: 1712kb

input:

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

output:

0 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 427 42...

result:

ok Accepted

Test #40:

score: 0
Accepted
time: 271ms
memory: 1624kb

input:

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

output:

0 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 91...

result:

ok Accepted

Test #41:

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

input:

999
0
2
2
1
1
1
2
2
1
2
0
0
1
0
1
1
2
1
0
0
1
2
0
1
1
1
0
1
1
1
1
1
0
2
2
0
1
1
1
0
2
0
2
0
1
0
0
1
1
1
2
0
0
0
0
1
1
0
1
2
0
1
0
1
0
0
0
1
1
1
1
1
1
1
1
2
1
1
0
1
1
0
2
1
1
0
1
1
1
1
0
1
2
1
0
0
1
0
1
1
1
0
2
0
2
2
0
2
2
2
2
0
1
1
1
2
0
1
2
0
0
2
1
0
1
1
0
2
2
0
0
1
0
1
0
2
1
1
0
1
1
0
2
0
2
2
2
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

Extra Test:

score: 0
Extra Test Passed