QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#672923#9432. Permutationhuazai676AC ✓218ms3860kbC++171.8kb2024-10-24 19:52:312024-10-24 19:52:32

Judging History

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

  • [2024-10-24 19:52:32]
  • 评测
  • 测评结果:AC
  • 用时:218ms
  • 内存:3860kb
  • [2024-10-24 19:52:31]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<random>

using namespace std;

const int N=1010;

mt19937 rd(102937);

int n;
int p[N];

int Q(int l,int r,int x,int y)
{
    int mid=(l+r)/2;
    cout<<"0 ";
    for(int i=1;i<=mid;i++) cout<<x<<' ';
    for(int i=mid+1;i<=n;i++) cout<<y<<' ';
    cout<<endl;
    int res;
    cin>>res;
    return res;
}

void solve(int l,int r,vector<int> s)
{
    if(l==r)
    {
        p[l]=s[0];
        return;
    }
    int mid=(l+r)/2;
    shuffle(s.begin(),s.end(),rd);
    vector<int> ls,rs,tmp;
    for(int i=0;i<s.size();)
    {
        if(i<s.size()-1)
        {
            int x=s[i],y=s[i+1];
            int k=Q(l,r,x,y);
            if(k==1)
            {
                tmp.push_back(x);
                i+=1;
            }
            else if(k==2)
            {
                tmp.push_back(x);
                for(int t:tmp) ls.push_back(t);
                tmp.clear();
                rs.push_back(y);
                i+=2;
            }
            else
            {
                tmp.push_back(x);
                for(int t:tmp) rs.push_back(t);
                tmp.clear();
                ls.push_back(y);
                i+=2;
            }
        }
        else
        {
            int x=s[i];
            tmp.push_back(x);
            if(ls.size()<=rs.size()) for(int t:tmp) ls.push_back(t);
            else for(int t:tmp) rs.push_back(t);
            i+=1;
        }
    }
    solve(l,mid,ls),solve(mid+1,r,rs);
}

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    vector<int> s;
    for(int i=1;i<=n;i++) s.push_back(i);
    solve(1,n,s);
    cout<<"1 ";
    for(int i=1;i<=n;i++) cout<<p[i]<<' ';
    cout<<endl;

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
1
1
2
2
0
0

output:

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

result:

ok Accepted

Test #2:

score: 0
Accepted
time: 172ms
memory: 3576kb

input:

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

output:

0 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 52...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1 

result:

ok Accepted

Test #4:

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

input:

2
0

output:

0 1 2 
1 2 1 

result:

ok Accepted

Test #5:

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

input:

3
2
2

output:

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

result:

ok Accepted

Test #6:

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

input:

4
0
0
2
0

output:

0 1 1 3 3 
0 2 2 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: 0ms
memory: 3540kb

input:

6
0
0
2
2
2
0
2

output:

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

result:

ok Accepted

Test #8:

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

input:

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

output:

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

result:

ok Accepted

Test #9:

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

input:

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

output:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

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

input:

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

output:

0 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 52...

result:

ok Accepted

Test #18:

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

input:

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

output:

0 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 52...

result:

ok Accepted

Test #19:

score: 0
Accepted
time: 197ms
memory: 3560kb

input:

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

output:

0 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 52...

result:

ok Accepted

Test #20:

score: 0
Accepted
time: 213ms
memory: 3560kb

input:

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

output:

0 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 52...

result:

ok Accepted

Test #21:

score: 0
Accepted
time: 205ms
memory: 3580kb

input:

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

output:

0 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 52...

result:

ok Accepted

Test #22:

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

input:

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

output:

0 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 52...

result:

ok Accepted

Test #23:

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

input:

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

output:

0 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 52...

result:

ok Accepted

Test #24:

score: 0
Accepted
time: 205ms
memory: 3648kb

input:

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

output:

0 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 52...

result:

ok Accepted

Test #25:

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

input:

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

output:

0 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 52...

result:

ok Accepted

Test #26:

score: 0
Accepted
time: 212ms
memory: 3588kb

input:

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

output:

0 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 52...

result:

ok Accepted

Test #27:

score: 0
Accepted
time: 198ms
memory: 3588kb

input:

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

output:

0 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 52...

result:

ok Accepted

Test #28:

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

input:

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

output:

0 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 52...

result:

ok Accepted

Test #29:

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

input:

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

output:

0 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 52...

result:

ok Accepted

Test #30:

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

input:

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

output:

0 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 52...

result:

ok Accepted

Test #31:

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

input:

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

output:

0 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 52...

result:

ok Accepted

Test #32:

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

input:

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

output:

0 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 52...

result:

ok Accepted

Test #33:

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

input:

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

output:

0 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 52...

result:

ok Accepted

Test #34:

score: 0
Accepted
time: 205ms
memory: 3648kb

input:

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

output:

0 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 52...

result:

ok Accepted

Test #35:

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

input:

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

output:

0 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 52...

result:

ok Accepted

Test #36:

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

input:

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

output:

0 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 52...

result:

ok Accepted

Test #37:

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

input:

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

output:

0 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 52...

result:

ok Accepted

Test #38:

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

input:

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

output:

0 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 52...

result:

ok Accepted

Test #39:

score: 0
Accepted
time: 191ms
memory: 3520kb

input:

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

output:

0 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 52...

result:

ok Accepted

Test #40:

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

input:

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

output:

0 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 52...

result:

ok Accepted

Test #41:

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

input:

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

output:

0 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 524 52...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed