QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#745343#9432. PermutationLazy_LabsAC ✓290ms4144kbC++141.5kb2024-11-14 09:18:392024-11-14 09:18:39

Judging History

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

  • [2024-11-14 09:18:39]
  • 评测
  • 测评结果:AC
  • 用时:290ms
  • 内存:4144kb
  • [2024-11-14 09:18:39]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int x(0),f(1);char c=getchar();
	while(c<'0'||c>'9')f=c=='-'?-1:1,c=getchar();
	while(c<='9'&&c>='0')x=x*10+c-48,c=getchar();
	return x*f;
}
const int N=1010;
int p[N],n;vector<int>All;
int ask(int mid,int x,int y){
    printf("0 ");
    for(int i=1;i<=n;i++)printf("%d ",(i<=mid)?x:y);puts("");
    fflush(stdout);return read();
}
queue<int>q;int fa[N],to[N];
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
void solve(int l,int r,vector<int>nw){
    if(l==r)return p[l]=nw[0],void();
    int mid=(l+r)>>1;for(auto i:nw)q.push(i),fa[i]=i,to[i]=-1;
    int Pl=0,Pr=0;
    while(!q.empty()){
        if(q.size()==1){
            int x=q.front();q.pop();
            if(Pl)to[x]=!ask(mid,x,Pl);
            else if(Pr)to[x]=!ask(mid,Pr,x);
        }
        else {
            int x=q.front();q.pop();int y=q.front();q.pop();
            int qry=ask(mid,x,y);
            if(qry==0)to[x]=1,to[y]=0,Pl=y,Pr=x;
            else if(qry==2)to[x]=0,to[y]=1,Pl=x,Pr=y;
            else q.push(x),fa[find(y)]=find(x);
        }
    }
    vector<int>L,R;
    for(auto i:nw)if(!to[find(i)])L.push_back(i);else R.push_back(i);
    solve(l,mid,L);solve(mid+1,r,R);
}
mt19937 rnd(0xee0000);
int main(){
    n=read();for(int i=1;i<=n;i++)All.push_back(i);shuffle(All.begin(),All.end(),rnd);
    solve(1,n,All);printf("1 ");for(int i=1;i<=n;i++)printf("%d ",p[i]);fflush(stdout);
    return 0;
}

詳細信息

Test #1:

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

input:

5
1
1
1
0
1
0
2
0

output:

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

result:

ok Accepted

Test #2:

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

input:

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

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

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

input:

1

output:

1 1 

result:

ok Accepted

Test #4:

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

input:

2
2

output:

0 2 1 
1 2 1 

result:

ok Accepted

Test #5:

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

input:

3
1
0
2

output:

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

result:

ok Accepted

Test #6:

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

input:

4
1
1
2
0
0

output:

0 4 4 3 3 
0 1 1 2 2 
0 4 4 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: 3780kb

input:

6
1
0
1
2
1
0
0
1
0
0

output:

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

input:

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

output:

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

input:

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

output:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

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

input:

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

output:

0 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 1...

result:

ok Accepted

Test #18:

score: 0
Accepted
time: 250ms
memory: 4068kb

input:

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

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

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

input:

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

output:

0 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 1...

result:

ok Accepted

Test #20:

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

input:

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

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

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

input:

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

output:

0 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 1...

result:

ok Accepted

Test #22:

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

input:

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

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

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

input:

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

output:

0 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 1...

result:

ok Accepted

Test #24:

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

input:

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

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

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

input:

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

output:

0 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 1...

result:

ok Accepted

Test #26:

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

input:

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

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

score: 0
Accepted
time: 290ms
memory: 4036kb

input:

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

output:

0 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 1...

result:

ok Accepted

Test #28:

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

input:

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

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

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

input:

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

output:

0 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 1...

result:

ok Accepted

Test #30:

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

input:

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

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

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

input:

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

output:

0 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 1...

result:

ok Accepted

Test #32:

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

input:

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

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

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

input:

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

output:

0 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 1...

result:

ok Accepted

Test #34:

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

input:

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

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

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

input:

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

output:

0 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 1...

result:

ok Accepted

Test #36:

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

input:

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

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

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

input:

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

output:

0 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 1...

result:

ok Accepted

Test #38:

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

input:

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

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

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

input:

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

output:

0 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 1...

result:

ok Accepted

Test #40:

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

input:

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

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

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

input:

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

output:

0 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 1...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed