QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#746701#9432. PermutationJerrywangAC ✓277ms4184kbC++142.0kb2024-11-14 15:18:292024-11-14 15:18:30

Judging History

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

  • [2024-11-14 15:18:30]
  • 评测
  • 测评结果:AC
  • 用时:277ms
  • 内存:4184kb
  • [2024-11-14 15:18:29]
  • 提交

answer

// QOJ9432 Permutation
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define rep(i, s, t) for(int i=s; i<=t; ++i)
#define debug(x) cerr<<#x<<":"<<x<<endl;
const int N=1005;
using namespace std;
mt19937 rnd(time(0));
char buf[1<<23], *p1=buf, *p2=buf;
#define gc() getchar()
inline int read()
{
    int x=0, f=1; char c=gc();
    while(c<'0' || c>'9') c=='-' && (f=-1), c=gc();
    while('0'<=c && c<='9') x=(x<<3)+(x<<1)+c-'0', c=gc();
    return x*f;
}

int n, ans[N];
int query(int mid, int x, int y)
{
    printf("0");
    rep(i, 1, mid) printf(" %d", x);
    rep(i, mid+1, n) printf(" %d", y);
    puts(""); fflush(stdout);
    return read();
}
int fa[N];
int root(int u) {return fa[u]==u?u:fa[u]=root(fa[u]);}
void dfs(int l, int r, vector<int> a)
{
    if(l>r) return;
    if(l==r) return ans[l]=a[0], void();
    vector<int> L, R, b, LL, RR;
    for(int x:a) fa[x]=x;
    int mid=l+r>>1;
    shuffle(a.begin(), a.end(), rnd);
    while(a.size()>1)
    {
        int x=a.back(); a.pop_back(); int y=a.back(); a.pop_back();
        int ret=query(mid, x, y);
        if(ret==0) L.pb(y), R.pb(x);
        else if(ret==1) a.pb(x), b.pb(y), fa[root(y)]=root(x);
        else L.pb(x), R.pb(y);
    }
    if(a.size())
    {
        int x=a.back();
        if(L.size())
        {
            int ret=query(mid, L[0], x);
            if(ret==1) L.pb(x);
            else R.pb(x);
        }
        else if(R.size())
        {
            int ret=query(mid, x, R[0]);
            if(ret==1) R.pb(x);
            else L.pb(x);
        }
    }
    LL.clear(), RR.clear();
    for(int x:L)
    {
        for(int y:b) if(root(y)==root(x)) LL.pb(y);
    }
    for(int x:R)
    {
        for(int y:b) if(root(y)==root(x)) RR.pb(y);
    }
    for(int x:LL) L.pb(x);
    for(int x:RR) R.pb(x);
    dfs(l, mid, L), dfs(mid+1, r, R);
}

int main()
{
    n=read(); vector<int> a;
    rep(i, 1, n) a.pb(i);
    dfs(1, n, a);
    printf("1");
    rep(i, 1, n) printf(" %d", ans[i]);

    return 0;
}

詳細信息

Test #1:

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

input:

5
2
2
1
0
1
0
2

output:

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

result:

ok Accepted

Test #2:

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

input:

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

output:

0 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 80...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1

result:

ok Accepted

Test #4:

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

input:

2
0

output:

0 1 2
1 2 1

result:

ok Accepted

Test #5:

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

input:

3
1
2
0

output:

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

result:

ok Accepted

Test #6:

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

input:

4
2
0
0
2

output:

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

result:

ok Accepted

Test #7:

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

input:

6
1
2
1
0
2
1
2
0
1
2

output:

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

input:

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

output:

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

result:

ok Accepted

Test #9:

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

input:

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

output:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

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

input:

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

output:

0 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 853 85...

result:

ok Accepted

Test #18:

score: 0
Accepted
time: 248ms
memory: 4184kb

input:

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

output:

0 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 974 97...

result:

ok Accepted

Test #19:

score: 0
Accepted
time: 250ms
memory: 3908kb

input:

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

output:

0 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 530 53...

result:

ok Accepted

Test #20:

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

input:

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

output:

0 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 23...

result:

ok Accepted

Test #21:

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

input:

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

output:

0 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 554 55...

result:

ok Accepted

Test #22:

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

input:

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

output:

0 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 18...

result:

ok Accepted

Test #23:

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

input:

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

output:

0 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 366 36...

result:

ok Accepted

Test #24:

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

input:

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

output:

0 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 77...

result:

ok Accepted

Test #25:

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

input:

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

output:

0 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 435 43...

result:

ok Accepted

Test #26:

score: 0
Accepted
time: 248ms
memory: 3824kb

input:

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

output:

0 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 539 53...

result:

ok Accepted

Test #27:

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

input:

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

output:

0 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 573 57...

result:

ok Accepted

Test #28:

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

input:

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

output:

0 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 484 48...

result:

ok Accepted

Test #29:

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

input:

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

output:

0 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 247 24...

result:

ok Accepted

Test #30:

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

input:

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

output:

0 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 84...

result:

ok Accepted

Test #31:

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

input:

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

output:

0 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 9...

result:

ok Accepted

Test #32:

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

input:

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

output:

0 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 483 48...

result:

ok Accepted

Test #33:

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

input:

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

output:

0 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 552 55...

result:

ok Accepted

Test #34:

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

input:

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

output:

0 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 51...

result:

ok Accepted

Test #35:

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

input:

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

output:

0 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 98...

result:

ok Accepted

Test #36:

score: 0
Accepted
time: 258ms
memory: 4180kb

input:

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

output:

0 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 794 79...

result:

ok Accepted

Test #37:

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

input:

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

output:

0 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 359 35...

result:

ok Accepted

Test #38:

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

input:

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

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

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

input:

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

output:

0 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 855 85...

result:

ok Accepted

Test #40:

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

input:

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

output:

0 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 8...

result:

ok Accepted

Test #41:

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

input:

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

output:

0 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 472 47...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed