QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#599313#9432. Permutationucup-team1134#AC ✓311ms3936kbC++232.8kb2024-09-29 03:18:432024-09-29 03:18:44

Judging History

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

  • [2024-09-29 03:18:44]
  • 评测
  • 测评结果:AC
  • 用时:311ms
  • 内存:3936kb
  • [2024-09-29 03:18:43]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vvii vector<vector<pair<int,int>>>
#define vvll vector<vector<pair<ll,ll>>>
#define vst vector<string>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define mkunique(x) sort(all(x));(x).erase(unique(all(x)),(x).end())
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005,INF=15<<26;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

vi P;
int ans=0;
int res[MAX];
int N;

void solve(vi S,int l,int r){
    //cout<<si(S)<<" "<<l<<" "<<r<<endl;
    if(si(S)==1){
        res[l]=S[0];
        return;
    }
    
    vi L,R;
    deque<vector<int>> Q;
    for(int x:S) Q.push_back({x});
    
    int m=(l+r)/2;
    
    while(si(Q)>=2){
        auto A=Q.front();Q.pop_front();
        auto B=Q.front();Q.pop_front();
        //ans++;
        cout<<0;
        for(int i=0;i<m;i++) cout<<" "<<A[0];
        for(int i=m;i<N;i++) cout<<" "<<B[0];
        cout<<endl;
        int z;cin>>z;
        if(z==2){
            for(int x:A) L.pb(x);
            for(int x:B) R.pb(x);
        }else if(z==1){
            for(int x:B) A.pb(x);
            Q.push_back(A);
        }else{
            for(int x:B) L.pb(x);
            for(int x:A) R.pb(x);
        }
    }
    
    if(si(Q)==1){
        auto A=Q.front();
        if(si(L)){
            cout<<0;
            for(int i=0;i<m;i++) cout<<" "<<L[0];
            for(int i=m;i<N;i++) cout<<" "<<A[0];
            cout<<endl;
            
            int z;cin>>z;
            
            if(z==2){
                for(int x:A) R.pb(x);
            }else{
                for(int x:A) L.pb(x);
            }
        }else{
            cout<<0;
            for(int i=0;i<m;i++) cout<<" "<<A[0];
            for(int i=m;i<N;i++) cout<<" "<<R[0];
            cout<<endl;
            
            int z;cin>>z;
            
            if(z==2){
                for(int x:A) L.pb(x);
            }else{
                for(int x:A) R.pb(x);
            }
        }
    }
    
    solve(L,l,m);
    solve(R,m,r);
}

int main(){
    
    cin>>N;
    P.resize(N);
    iota(all(P),1);
    shuffle(all(P),rng);
    
    solve(P,0,N);
    
    cout<<1;
    for(int i=0;i<N;i++) cout<<" "<<res[i];
    cout<<endl;
}



Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
0
2
2
2
0
2
0

output:

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

result:

ok Accepted

Test #2:

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

input:

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

output:

0 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 15...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1

result:

ok Accepted

Test #4:

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

input:

2
0

output:

0 1 2
1 2 1

result:

ok Accepted

Test #5:

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

input:

3
0
2
2

output:

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

result:

ok Accepted

Test #6:

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

input:

4
0
2
2
0

output:

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

input:

6
1
1
0
0
2
2
2
2
2
0

output:

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

result:

ok Accepted

Test #8:

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

input:

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

output:

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

result:

ok Accepted

Test #9:

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

input:

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

output:

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

result:

ok Accepted

Test #10:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

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

input:

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

output:

0 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 68...

result:

ok Accepted

Test #18:

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

input:

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

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

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

input:

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

output:

0 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 630 63...

result:

ok Accepted

Test #20:

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

input:

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

output:

0 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 18...

result:

ok Accepted

Test #21:

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

input:

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

output:

0 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 479 47...

result:

ok Accepted

Test #22:

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

input:

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

output:

0 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 63...

result:

ok Accepted

Test #23:

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

input:

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

output:

0 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 238 23...

result:

ok Accepted

Test #24:

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

input:

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

output:

0 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 553 55...

result:

ok Accepted

Test #25:

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

input:

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

output:

0 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 39...

result:

ok Accepted

Test #26:

score: 0
Accepted
time: 289ms
memory: 3640kb

input:

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

output:

0 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 119 11...

result:

ok Accepted

Test #27:

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

input:

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

output:

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

result:

ok Accepted

Test #28:

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

input:

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

output:

0 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 797 79...

result:

ok Accepted

Test #29:

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

input:

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

output:

0 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 712 71...

result:

ok Accepted

Test #30:

score: 0
Accepted
time: 308ms
memory: 3732kb

input:

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

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

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

input:

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

output:

0 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 73 7...

result:

ok Accepted

Test #32:

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

input:

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

output:

0 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 786 78...

result:

ok Accepted

Test #33:

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

input:

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

output:

0 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 901 90...

result:

ok Accepted

Test #34:

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

input:

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

output:

0 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 30...

result:

ok Accepted

Test #35:

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

input:

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

output:

0 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 73...

result:

ok Accepted

Test #36:

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

input:

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

output:

0 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 18...

result:

ok Accepted

Test #37:

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

input:

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

output:

0 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 22...

result:

ok Accepted

Test #38:

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

input:

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

output:

0 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 696 69...

result:

ok Accepted

Test #39:

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

input:

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

output:

0 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 825 82...

result:

ok Accepted

Test #40:

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

input:

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

output:

0 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 347 34...

result:

ok Accepted

Test #41:

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

input:

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

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