QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#597024#9432. Permutationucup-team3548#AC ✓285ms4116kbC++172.6kb2024-09-28 16:54:162024-09-28 16:54:16

Judging History

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

  • [2024-09-28 16:54:16]
  • 评测
  • 测评结果:AC
  • 用时:285ms
  • 内存:4116kb
  • [2024-09-28 16:54:16]
  • 提交

answer

#include<cstdio>
#include<algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <cassert>
#include <random>
#include <ctime>
#define ABS(X) ((X)>=0?(X):-(X))
#define LPos(X) Tree[Pos].Son[0]
#define RPos(X) Tree[Pos].Son[1]
using namespace std;

using ll = long long;
using ld = long double;

mt19937 Rand(random_device{}());
int N;
int Ans[1001];
int Output[1001];
int Stack[1001],Top;
int Oper()
{
    putchar('0');
    for(int i=1;i<=N;++i)
    printf(" %d",Output[i]);
    putchar('\n');
    fflush(stdout);
    int Res;
    scanf("%d",&Res);
    return Res;
}
void Find()
{
    putchar('1');
    for(int i=1;i<=N;++i)
    printf(" %d",Ans[i]);
    putchar('\n');
    fflush(stdout);
}
void Search(int L,int R,vector<int>Now)
{
    if(Now.size()==1)
    {
        Ans[L]=Now[0];
        return;
    }
    if(Now.size()==2)
    {
        for(int i=1;i<=N;++i)
        Output[i]=(i==R?Now[1]:Now[0]);
        if(Oper()==2)
        {
            Ans[L]=Now[0],Ans[R]=Now[1];
        }
        else Ans[L]=Now[1],Ans[R]=Now[0];
        return;
    }
    shuffle(Now.begin(),Now.end(),Rand);
    vector<int>Next[2];
    int Mid=((L+R)>>1);
    int Lrest=Mid-L+1,Rrest=R-Mid;
    int Pointer=0;
    while(Lrest&&Rrest)
    {
        int Left=Now[Pointer++];
        Top=0;
        while(Pointer<Now.size())
        {
            int Right=Now[Pointer++];
            for(int i=1;i<=N;++i)
            Output[i]=(i>Mid&&i<=R?Right:Left);
            int Op=Oper();
            if(Op==1)
            {
                Stack[++Top]=Right;
            }
            else if(Op==2)
            {
                Next[0].push_back(Left);
                Next[1].push_back(Right);
                for(int i=1;i<=Top;++i)
                Next[0].push_back(Stack[i]);
                Lrest-=Top+1,--Rrest;
                break;
            }
            else
            {
                Next[1].push_back(Left);
                Next[0].push_back(Right);
                for(int i=1;i<=Top;++i)
                Next[1].push_back(Stack[i]);
                Rrest-=Top+1,--Lrest;
                break;
            }
        }
    }
    while(Pointer<Now.size()&&Lrest)
    {
        Next[0].push_back(Now[Pointer++]);
        --Lrest;
    }
    while(Pointer<Now.size()&&Rrest)
    {
        Next[1].push_back(Now[Pointer++]);
        --Rrest;
    }
    Search(L,Mid,Next[0]);
    Search(Mid+1,R,Next[1]);
}
int main()
{
    scanf("%d",&N);
    vector<int>Prime;
    for(int i=1;i<=N;++i)
    {
        Prime.push_back(i);
    }
    Search(1,N,Prime);
    Find();
}

詳細信息

Test #1:

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

input:

5
0
1
2
1
2
0
0

output:

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

input:

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

output:

0 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 24...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1

result:

ok Accepted

Test #4:

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

input:

2
0

output:

0 1 2
1 2 1

result:

ok Accepted

Test #5:

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

input:

3
0
2

output:

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

result:

ok Accepted

Test #6:

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

input:

4
2
2
2
2

output:

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

result:

ok Accepted

Test #7:

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

input:

6
1
0
2
0
0
2
0

output:

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

result:

ok Accepted

Test #8:

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

input:

7
1
2
2
2
2
0
2
2
2
0

output:

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

result:

ok Accepted

Test #9:

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

input:

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

output:

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

result:

ok Accepted

Test #10:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

score: 0
Accepted
time: 226ms
memory: 3836kb

input:

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

output:

0 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 18...

result:

ok Accepted

Test #18:

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

input:

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

output:

0 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 625 62...

result:

ok Accepted

Test #19:

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

input:

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

output:

0 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 87...

result:

ok Accepted

Test #20:

score: 0
Accepted
time: 239ms
memory: 4072kb

input:

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

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

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

input:

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

output:

0 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 766 76...

result:

ok Accepted

Test #22:

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

input:

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

output:

0 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 12...

result:

ok Accepted

Test #23:

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

input:

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

output:

0 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 756 75...

result:

ok Accepted

Test #24:

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

input:

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

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

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

input:

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

output:

0 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 583 58...

result:

ok Accepted

Test #26:

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

input:

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

output:

0 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 847 84...

result:

ok Accepted

Test #27:

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

input:

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

output:

0 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 412 41...

result:

ok Accepted

Test #28:

score: 0
Accepted
time: 231ms
memory: 4076kb

input:

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

output:

0 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 973 97...

result:

ok Accepted

Test #29:

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

input:

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

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

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

input:

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

output:

0 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 61...

result:

ok Accepted

Test #31:

score: 0
Accepted
time: 243ms
memory: 4068kb

input:

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

output:

0 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 914 91...

result:

ok Accepted

Test #32:

score: 0
Accepted
time: 231ms
memory: 3828kb

input:

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

output:

0 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 52...

result:

ok Accepted

Test #33:

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

input:

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

output:

0 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 49...

result:

ok Accepted

Test #34:

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

input:

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

output:

0 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 963 96...

result:

ok Accepted

Test #35:

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

input:

993
1
0
1
0
2
1
2
0
2
1
0
1
1
1
1
1
1
1
2
2
2
0
0
1
1
1
0
1
1
0
0
1
2
2
0
1
2
0
1
0
0
1
2
0
0
1
2
2
0
1
2
1
2
1
1
0
1
1
1
0
2
1
1
0
0
0
2
0
0
2
2
2
1
1
1
0
0
1
2
1
1
2
1
1
1
1
2
1
2
2
1
2
2
1
1
2
0
1
0
1
0
0
1
1
0
2
0
2
1
1
1
2
1
0
0
1
0
1
1
1
1
1
2
0
0
2
2
1
0
2
1
0
2
1
1
1
1
1
0
1
1
2
2
1
0
1
0
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 #36:

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

input:

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

output:

0 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 832 83...

result:

ok Accepted

Test #37:

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

input:

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

output:

0 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 589 58...

result:

ok Accepted

Test #38:

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

input:

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

output:

0 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 187 18...

result:

ok Accepted

Test #39:

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

input:

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

output:

0 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 466 46...

result:

ok Accepted

Test #40:

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

input:

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

output:

0 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 606 60...

result:

ok Accepted

Test #41:

score: 0
Accepted
time: 232ms
memory: 3892kb

input:

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

output:

0 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 30...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed