QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#596305#9432. Permutationucup-team5071#AC ✓303ms3988kbC++204.1kb2024-09-28 15:29:372024-09-28 15:29:37

Judging History

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

  • [2024-09-28 15:29:37]
  • 评测
  • 测评结果:AC
  • 用时:303ms
  • 内存:3988kb
  • [2024-09-28 15:29:37]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int B=2) {
	return (unsigned long long)rng() % B;
}
const bool rand_test=false;
struct Interactor{
    int n;
    vector<int> a;
    int tot=0;
    void init(int _n){
        n=_n;
        tot=0;
        if(rand_test){
            a.resize(n+1);
            for(int i=1;i<=n;i++)a[i]=i;
            random_shuffle(a.begin()+1,a.end());
            cout<<"random_a : ";for(int i=1;i<=n;i++)cout<<a[i]<<" ";;cout<<endl;
        }
    }
    int query(vector<int> b){
        tot++;
        assert(tot<=6666);
        cout<<"0 "<<b[1];
        for(int i=2;i<=n;i++)cout<<" "<<b[i];
        cout<<endl;
        if(rand_test){
            int cnt=0;
            for(int i=1;i<=n;i++)cnt+=(a[i]==b[i]);
            return cnt;
        }
        int z;cin>>z;return z;
    }
    void answer(vector<int>b){
        cout<<"1 "<<b[1];
        for(int i=2;i<=n;i++)cout<<" "<<b[i];
        cout<<endl;
        if(rand_test){
            int cnt=0;
            for(int i=1;i<=n;i++)cnt+=(a[i]==b[i]);
            assert(cnt==n);
            cout<<"tot="<<tot<<endl;
        }
        
    }
}sol;
int solve()
{
    srand(time(NULL));
    int n;
    if(rand_test)n=1000;
    else cin>>n;
    sol.init(n);
    if(n<=5){
        vector<int>ans(n+1);
        iota(ans.begin(),ans.end(),0);
        do{
            if(sol.query(ans)==n){
                sol.answer(ans);
                return 0;
            }
        }while(next_permutation(ans.begin()+1,ans.end()));
        return 0;
    }
    // int zero=2;
    // for(int i=1;i<=n;i++)if(i!=2){
    //     vector<int> b(n+1);
    //     b[1]=i;
    //     for(int j=2;j<=n;j++)b[j]=2;
    //     int q=sol.query(b);
    //     if(q==0)break;
    //     if(q==2){zero=i;break;}
    // }
    vector<int>ans(n+1);
    // ans[1]=zero;
    // cout<<"zero = "<<zero<<endl;
    auto zero = [&](int a,int b){
        for(int i=1;i<=n;i++)if(i!=a&&i!=b)return i;
        return -1;
    };
    function<void(int,int,vector<int>)> dfs = [&](int l,int r,vector<int>a){
        random_shuffle(a.begin(),a.end());
        // cout<<"dfs l ="<<l<<" r="<<r<<" a :";for(auto it:a)cout<<it<<" ";;;cout<<endl;
        if(r-l+1==1){
            ans[l]=a.back();
            return;
        }
        if(r-l+1==2){
            vector<int>b(n+1,a[0]);
            b[r]=zero(a[0],a[1]);
            if(sol.query(b)==1){
                ans[l]=a[0],ans[r]=a[1];
            }
            else ans[l]=a[1],ans[r]=a[0];
            return;
        }
        int mid=(l+r)/2;
        vector<int>L,R;
        vector<int> v;
        for(int i=0;i<(int)a.size();i++){
            v.push_back(a[i]);
            while(i+1<a.size()){
                int t[2]={v.back(),a[i+1]};
                vector<int> b(n+1);
                for(int j=1;j<=n;j++){
                    if(j>=l&&j<=mid)b[j]=t[0];
                    else if(j>mid&&j<=r)b[j]=t[1];
                    else b[j]=t[0];
                }
                int q=sol.query(b);
                if(q==2){
                    for(auto it:v)L.push_back(it);
                    R.push_back(t[1]);
                    v.clear();
                    i++;
                    break;
                }
                else if(q==0){
                    L.push_back(t[1]);
                    for(auto it:v)R.push_back(it);
                    v.clear();
                    i++;
                    break;
                }
                else{
                    v.push_back(a[i+1]);
                    i++;
                }
            }
        }
        if(!v.empty()){
            if(L.size()<mid-l+1){
                for(auto it:v)L.push_back(it);
            }
            else {
                for(auto it:v)R.push_back(it);
            }
        }
        dfs(l,mid,L);
        dfs(mid+1,r,R);
    };
    vector<int> b(n);iota(b.begin(),b.end(),1);
    dfs(1,n,b);
    sol.answer(ans);
    return 0;
}
int main()
{
    int T=1;;
    while(T--)solve();
}

詳細信息

Test #1:

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

input:

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

output:

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

result:

ok Accepted

Test #2:

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

input:

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

output:

0 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 477 47...

result:

ok Accepted

Test #3:

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

input:

1
1

output:

0 1
1 1

result:

ok Accepted

Test #4:

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

input:

2
0
2

output:

0 1 2
0 2 1
1 2 1

result:

ok Accepted

Test #5:

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

input:

3
0
1
1
0
3

output:

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

result:

ok Accepted

Test #6:

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

input:

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

output:

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

result:

ok Accepted

Test #7:

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

input:

6
1
0
0
1
2
1
1
2
1

output:

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

result:

ok Accepted

Test #8:

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

input:

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

output:

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

result:

ok Accepted

Test #9:

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

input:

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

output:

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

result:

ok Accepted

Test #10:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

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

input:

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

output:

0 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 33...

result:

ok Accepted

Test #18:

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

input:

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

output:

0 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 35...

result:

ok Accepted

Test #19:

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

input:

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

output:

0 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 16...

result:

ok Accepted

Test #20:

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

input:

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

output:

0 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 14...

result:

ok Accepted

Test #21:

score: 0
Accepted
time: 286ms
memory: 3848kb

input:

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

output:

0 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 4...

result:

ok Accepted

Test #22:

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

input:

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

output:

0 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 12...

result:

ok Accepted

Test #23:

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

input:

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

output:

0 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 14...

result:

ok Accepted

Test #24:

score: 0
Accepted
time: 284ms
memory: 3884kb

input:

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

output:

0 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 49...

result:

ok Accepted

Test #25:

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

input:

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

output:

0 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 496 49...

result:

ok Accepted

Test #26:

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

input:

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

output:

0 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 167 16...

result:

ok Accepted

Test #27:

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

input:

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

output:

0 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 348 34...

result:

ok Accepted

Test #28:

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

input:

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

output:

0 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 24...

result:

ok Accepted

Test #29:

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

input:

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

output:

0 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 257 25...

result:

ok Accepted

Test #30:

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

input:

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

output:

0 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 322 32...

result:

ok Accepted

Test #31:

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

input:

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

output:

0 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 317 31...

result:

ok Accepted

Test #32:

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

input:

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

output:

0 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 89...

result:

ok Accepted

Test #33:

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

input:

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

output:

0 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 813 81...

result:

ok Accepted

Test #34:

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

input:

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

output:

0 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 40...

result:

ok Accepted

Test #35:

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

input:

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

output:

0 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 704 70...

result:

ok Accepted

Test #36:

score: 0
Accepted
time: 291ms
memory: 3972kb

input:

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

output:

0 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 5...

result:

ok Accepted

Test #37:

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

input:

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

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

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

input:

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

output:

0 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 97...

result:

ok Accepted

Test #39:

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

input:

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

output:

0 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 702 70...

result:

ok Accepted

Test #40:

score: 0
Accepted
time: 301ms
memory: 3844kb

input:

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

output:

0 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 72...

result:

ok Accepted

Test #41:

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

input:

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

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

Extra Test:

score: 0
Extra Test Passed