QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#687905#9432. PermutationjimmyywangAC ✓279ms4412kbC++141.9kb2024-10-29 21:49:172024-10-29 21:49:19

Judging History

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

  • [2024-10-29 21:49:19]
  • 评测
  • 测评结果:AC
  • 用时:279ms
  • 内存:4412kb
  • [2024-10-29 21:49:17]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll int
#define f(i,a,b) for(int i=a;i<=b;i++)
ll rd(){
	ll x=0,f=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')f=-1;
		c=getchar();
	}while(isdigit(c)){
		x=x*10+c-'0';
		c=getchar();
	}return x*f;
}
#define d rd()
ll n;
ll ask(ll x,ll y,ll mid){
    putchar('0');
    f(i,1,mid)printf(" %d",x);
    f(i,mid+1,n)printf(" %d",y);cout<<endl;
    fflush(stdout);
    return d;
}
ll fa[10010];
ll find(ll x){if(fa[x]==x)return x;return fa[x]=find(fa[x]);}
void un(ll u,ll v){fa[find(u)]=find(v);}
ll res[100010];
void work(ll l,ll r,set<ll>st){
    // printf("Now Running: (%d, %d)  ",l,r);
    // cout<<"{";for(auto i:st)cout<<i<<" ";cout<<"}.\n";
    if(l==r){res[l]=*(st.begin());return;}
    ll mid=l+r>>1;
    set<ll>lf,ri,ss;lf.clear(),ri.clear();ss=st;
    for(auto i:st)fa[i]=i;
    ll L=n+1,R=n+2;fa[L]=L,fa[R]=R;
    while(st.size()>1){
        ll x=rand()%(st.size()-1),y=rand()%(st.size()-x-1)+x+1;
        ll xx,yy;
        auto it=st.begin();if(x==0)xx=*it;
        f(i,1,y){++it;
            if(x==i)xx=*it;
            if(y==i)yy=*it;
        }x=xx,y=yy;ll o=ask(x,y,mid);
        if(o==0)un(x,R),un(y,L),st.erase(x),st.erase(y);
        if(o==2)un(x,L),un(y,R),st.erase(x),st.erase(y);
        if(o==1){
            un(x,y);
            st.erase(x);
        }
    }for(auto i:ss){
        if(find(i)==find(L))lf.insert(i);
        else if(find(i)==find(R))ri.insert(i);
    }if(st.size()){
        ll x=*(st.begin());
        if(lf.size()!=(mid-l+1)){
            for(auto i:ss)if(find(i)==find(x))lf.insert(i);
        }
        else {
            for(auto i:ss)if(find(i)==find(x))ri.insert(i);
        }
    }
    work(l,mid,lf);work(mid+1,r,ri);
}
set<ll>st;
int main(){
    srand(time(0));
    n=d;f(i,1,n)st.insert(i);
    work(1,n,st);cout<<1<<" ";
    f(i,1,n)cout<<res[i]<<" ";cout<<endl;
	return 0;
}

詳細信息

Test #1:

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

input:

5
1
2
0
0
2
2

output:

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

input:

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

output:

0 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 961 96...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1 

result:

ok Accepted

Test #4:

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

input:

2
0

output:

0 1 2
1 2 1 

result:

ok Accepted

Test #5:

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

input:

3
0
0

output:

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

result:

ok Accepted

Test #6:

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

input:

4
1
0
2
0

output:

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

result:

ok Accepted

Test #7:

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

input:

6
1
2
0
0
2
2
2

output:

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

result:

ok Accepted

Test #8:

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

input:

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

output:

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

result:

ok Accepted

Test #9:

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

input:

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

output:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

11
0
2
2
0
0
2
0
0
2
2
2
2
0
0
0
2
2

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

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

input:

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

output:

0 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 53...

result:

ok Accepted

Test #18:

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

input:

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

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

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

input:

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

output:

0 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 29...

result:

ok Accepted

Test #20:

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

input:

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

output:

0 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 416 41...

result:

ok Accepted

Test #21:

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

input:

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

output:

0 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 36...

result:

ok Accepted

Test #22:

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

input:

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

output:

0 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 83...

result:

ok Accepted

Test #23:

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

input:

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

output:

0 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 16...

result:

ok Accepted

Test #24:

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

input:

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

output:

0 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 97...

result:

ok Accepted

Test #25:

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

input:

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

output:

0 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 5...

result:

ok Accepted

Test #26:

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

input:

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

output:

0 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 30...

result:

ok Accepted

Test #27:

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

input:

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

output:

0 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 58...

result:

ok Accepted

Test #28:

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

input:

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

output:

0 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 970 97...

result:

ok Accepted

Test #29:

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

input:

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

output:

0 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 796 79...

result:

ok Accepted

Test #30:

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

input:

988
1
1
0
2
1
1
1
2
1
1
1
1
1
0
1
1
0
2
0
1
1
1
0
2
1
1
1
0
1
2
1
2
1
0
2
1
1
0
1
1
0
2
2
2
0
1
2
2
2
2
1
2
0
0
0
2
0
0
1
2
0
1
1
0
0
1
1
1
0
1
0
1
1
1
2
1
1
0
1
1
2
1
1
0
1
0
1
0
1
2
1
1
1
2
1
1
2
1
1
0
0
2
0
2
0
0
2
2
0
1
1
1
1
1
2
2
0
1
2
0
2
1
0
2
0
0
2
2
1
2
2
2
0
1
1
2
0
2
1
2
1
1
2
2
1
1
1
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 #31:

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

input:

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

output:

0 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 251 25...

result:

ok Accepted

Test #32:

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

input:

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

output:

0 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 173 17...

result:

ok Accepted

Test #33:

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

input:

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

output:

0 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 98...

result:

ok Accepted

Test #34:

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

input:

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

output:

0 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 94...

result:

ok Accepted

Test #35:

score: 0
Accepted
time: 246ms
memory: 4104kb

input:

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

output:

0 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 47...

result:

ok Accepted

Test #36:

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

input:

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

output:

0 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 84...

result:

ok Accepted

Test #37:

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

input:

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

output:

0 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 964 96...

result:

ok Accepted

Test #38:

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

input:

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

output:

0 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 6...

result:

ok Accepted

Test #39:

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

input:

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

output:

0 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 6...

result:

ok Accepted

Test #40:

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

input:

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

output:

0 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 987 98...

result:

ok Accepted

Test #41:

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

input:

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

Extra Test:

score: 0
Extra Test Passed