QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#612349#9432. PermutationMu_SilkAC ✓309ms3952kbC++202.0kb2024-10-05 10:38:422024-10-05 10:38:42

Judging History

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

  • [2024-10-05 10:38:42]
  • 评测
  • 测评结果:AC
  • 用时:309ms
  • 内存:3952kb
  • [2024-10-05 10:38:42]
  • 提交

answer

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

int n;
vector<int> fa;
vector<int> a;

int find(int x){
    return x==fa[x]?x:fa[x]=find(fa[x]);
}

void calc(int l,int r){
    if(l==r)return;
    vector<int> qu(n+1);
    int m=(l+r)/2;
    for(int i=1;i<=l-1;i++)qu[i]=a[l];
    for(int i=r+1;i<=n;i++)qu[i]=a[l];

    queue<int> u;
    for(int i=l;i<=r;i++){
        u.push(a[i]);
        fa[a[i]]=a[i];
    }
    int l0=l,r0=r;
    while (u.size()>=2){
        int x=u.front();u.pop();
        int y=u.front();u.pop();
        for(int i=l;i<=m;i++)qu[i]=x;
        for(int i=m+1;i<=r;i++)qu[i]=y;
        // cerr<<x<<" "<<y<<"\n";
        
        cout<<"0 ";
        for(int i=1;i<=n;i++)cout<<qu[i]<<" ";
        cout<<endl;

        int t;cin>>t;
        if(t==0){
            for(int i=l0;i<=r0;i++){
                if(find(a[i])==find(x)){
                    swap(a[i],a[r0]);
                    r0--;
                    i--;
                }
                else if(find(a[i])==find(y)){
                    swap(a[i],a[l0]);
                    l0++;
                }
            }
        }
        else if(t==2){
            for(int i=l0;i<=r0;i++){
                if(find(a[i])==find(x)){
                    swap(a[i],a[l0]);
                    l0++;
                }
                else if(find(a[i])==find(y)){
                    swap(a[i],a[r0]);
                    r0--;
                    i--;
                }
            }
        }
        else{
            fa[find(x)]=find(y);
            u.push(y);
        }
    }
    calc(l,m);
    calc(m+1,r);
}

void solve(){
    mt19937_64 gen(time(NULL));
    cin>>n;

    a.resize(n+1);
    fa.resize(n+1);

    for(int i=1;i<=n;i++)a[i]=i;
    shuffle(a.begin()+1,a.end(),gen);

    calc(1,n);
    cout<<"1 ";
    for(int i=1;i<=n;i++)cout<<a[i]<<" ";
    cout<<endl;
}

int main(){
    int n=1;
    //cin>>n;
    while(n--)solve();
    return 0;
}

詳細信息

Test #1:

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

input:

5
1
0
0
2
0
0

output:

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

result:

ok Accepted

Test #2:

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

input:

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

output:

0 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 85...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1 

result:

ok Accepted

Test #4:

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

input:

2
0

output:

0 1 2 
1 2 1 

result:

ok Accepted

Test #5:

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

input:

3
1
0
0

output:

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

result:

ok Accepted

Test #6:

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

input:

4
0
0
2
2

output:

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

result:

ok Accepted

Test #7:

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

input:

6
1
0
1
0
2
0
1
0
2

output:

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

result:

ok Accepted

Test #8:

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

input:

7
2
0
2
1
1
0
2
2
0
2

output:

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

result:

ok Accepted

Test #9:

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

input:

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

output:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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 8 8 8 8 8 8 8 
0 7 7 7 7 7 7 7 7 12 12 12 12 12 12 12 
0 3 3 3 3 3 3 3 3 14 14 14 14 14 14 14 
0 15 15 15 15 15 15 15 15 1 1 1 1 1 1 1 
0 13 13 13 13 13 13 13 13 4 4 4 4 4 4 4 
0 5 5 5 5 5 5 5 5 9 9 9 9 9 9 9 
0 2 2 2 2 2 2 2 2 11 11 ...

result:

ok Accepted

Test #17:

score: 0
Accepted
time: 283ms
memory: 3932kb

input:

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

output:

0 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 60...

result:

ok Accepted

Test #18:

score: 0
Accepted
time: 295ms
memory: 3664kb

input:

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

output:

0 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 50...

result:

ok Accepted

Test #19:

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

input:

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

output:

0 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 15...

result:

ok Accepted

Test #20:

score: 0
Accepted
time: 304ms
memory: 3712kb

input:

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

output:

0 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 459 45...

result:

ok Accepted

Test #21:

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

input:

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

output:

0 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 904 90...

result:

ok Accepted

Test #22:

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

input:

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

output:

0 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 789 78...

result:

ok Accepted

Test #23:

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

input:

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

output:

0 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 27...

result:

ok Accepted

Test #24:

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

input:

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

output:

0 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 38...

result:

ok Accepted

Test #25:

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

input:

983
2
0
2
1
1
0
1
1
1
1
1
1
1
1
2
1
0
0
0
1
1
0
2
1
0
1
0
0
0
0
1
0
1
1
0
1
0
0
1
0
0
1
2
1
0
0
1
0
0
0
2
1
1
2
1
1
1
1
1
0
2
2
2
1
0
1
2
1
0
0
0
1
0
1
1
1
2
0
2
1
0
1
0
0
1
1
1
2
0
2
2
1
0
0
0
1
2
1
1
0
2
1
1
1
1
1
0
1
1
2
1
1
0
1
0
0
0
2
1
1
1
1
2
0
1
1
2
1
0
2
0
0
1
2
0
1
2
1
1
1
1
0
0
0
1
1
1
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 #26:

score: 0
Accepted
time: 302ms
memory: 3716kb

input:

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

output:

0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2...

result:

ok Accepted

Test #27:

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

input:

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

output:

0 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 357 35...

result:

ok Accepted

Test #28:

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

input:

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

output:

0 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 325 32...

result:

ok Accepted

Test #29:

score: 0
Accepted
time: 281ms
memory: 3716kb

input:

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

output:

0 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 91...

result:

ok Accepted

Test #30:

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

input:

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

output:

0 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 79 7...

result:

ok Accepted

Test #31:

score: 0
Accepted
time: 288ms
memory: 3668kb

input:

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

output:

0 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 86...

result:

ok Accepted

Test #32:

score: 0
Accepted
time: 309ms
memory: 3952kb

input:

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

output:

0 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 3...

result:

ok Accepted

Test #33:

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

input:

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

output:

0 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 205 20...

result:

ok Accepted

Test #34:

score: 0
Accepted
time: 281ms
memory: 3656kb

input:

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

output:

0 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 585 58...

result:

ok Accepted

Test #35:

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

input:

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

output:

0 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 36...

result:

ok Accepted

Test #36:

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

input:

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

output:

0 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 854 85...

result:

ok Accepted

Test #37:

score: 0
Accepted
time: 298ms
memory: 3704kb

input:

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

output:

0 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 3...

result:

ok Accepted

Test #38:

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

input:

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

output:

0 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 20...

result:

ok Accepted

Test #39:

score: 0
Accepted
time: 305ms
memory: 3708kb

input:

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

output:

0 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 17...

result:

ok Accepted

Test #40:

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

input:

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

output:

0 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 617 61...

result:

ok Accepted

Test #41:

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

input:

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

output:

0 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 75...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed