QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#620963#9432. PermutationYzm007AC ✓285ms4192kbC++142.7kb2024-10-07 22:56:272024-10-07 22:56:27

Judging History

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

  • [2024-10-07 22:56:27]
  • 评测
  • 测评结果:AC
  • 用时:285ms
  • 内存:4192kb
  • [2024-10-07 22:56:27]
  • 提交

answer

#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define pb push_back
#define dbg(x) cerr<<(#x)<<":"<<x<<" ";
#define dbg2(x) cerr<<(#x)<<":"<<x<<endl;
#define SZ(a) (int)(a.size())
#define sci(a) scanf("%d",&(a))
#define pt(a) printf("%d",a);
#define pte(a) printf("%d\n",a)
#define ptlle(a) printf("%lld\n",a)
#define debug(...) fprintf(stderr, __VA_ARGS__)
const int N=1e3+10;
int n,ans[N],q[N],par[N],to[N];
int find(int x){
    return par[x]==x?x:par[x]=find(par[x]);
}
int ask(){
    printf("0");
    rep(i,1,n){
        printf(" %d",q[i]);
    }
    printf("\n");
    fflush(stdout);
    int v;
    sci(v);
    return v;
}
void out(){
    printf("1");
    rep(i,1,n){
        printf(" %d",ans[i]);
    }
    printf("\n");
    fflush(stdout);
}
void sol(int l,int r,vector<int>x){
    //printf("l:%d r:%d ",l,r);
    //for(auto &v:x)printf("%d ",v);puts("");
    if(l==r){
        ans[l]=x[0];
        return;
    }
    for(auto &v:x)par[v]=v;
    int mid=(l+r)/2;
    vector<int>L,R,del;
    while(SZ(x)>1){
        random_shuffle(x.begin(),x.end());
        int u=x.back();x.pop_back();
        int v=x.back();x.pop_back();
        rep(i,1,n){
            if(i<=mid)q[i]=u;
            else q[i]=v;
        }
        int w=ask();
        if(!w)L.pb(v),R.pb(u),to[v]=0,to[u]=1;
        else if(w==2)L.pb(u),R.pb(v),to[u]=0,to[v]=1;
        else del.pb(v),x.pb(u),par[v]=u;
    }
    //printf("x:%d L:%d R:%d\n",SZ(x),SZ(L),SZ(R));
    if(SZ(x)==1){
        int u=x[0];
        if(SZ(L)){
            rep(i,1,n){
                if(i<=mid)q[i]=u;
                else q[i]=L[0];
            }
            int w=ask();
            if(!w)R.pb(u),to[u]=1;
            else L.pb(u),to[u]=0;
        }
        else if(SZ(R)){
            rep(i,1,n){
                if(i<=mid)q[i]=R[0];
                else q[i]=u;
            }
            int w=ask();
            if(!w)L.pb(u),to[u]=0;
            else R.pb(u),to[u]=1;
        }
        else{
            assert(false);
        }
    }
    for(auto &v:del){
        int fa=find(v);
        if(!to[fa])L.pb(v);
        else R.pb(v);
    }
    if(SZ(L))sol(l,mid,L);
    if(SZ(R))sol(mid+1,r,R);
}
void sol(){
    if(n==1){
        ans[1]=1;
        out();
        return;
    }
    vector<int>now;
    rep(i,1,n)now.pb(i);
    sol(1,n,now);
    out();
}
int main(){
    srand(time(NULL));
    sci(n);
    sol();
    return 0;
}
//2 3 4 1 5

詳細信息

Test #1:

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

input:

5
2
1
0
2
1
0
0

output:

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

input:

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

output:

0 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 55...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1

result:

ok Accepted

Test #4:

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

input:

2
0

output:

0 1 2
1 2 1

result:

ok Accepted

Test #5:

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

input:

3
0
1
2

output:

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

result:

ok Accepted

Test #6:

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

input:

4
1
1
0
2
0

output:

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

input:

6
2
2
0
1
0
2
1
0
2

output:

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

input:

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

output:

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

input:

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

output:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

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

input:

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

output:

0 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 209 20...

result:

ok Accepted

Test #18:

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

input:

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

output:

0 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 86...

result:

ok Accepted

Test #19:

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

input:

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

output:

0 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 535 53...

result:

ok Accepted

Test #20:

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

input:

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

output:

0 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 714 71...

result:

ok Accepted

Test #21:

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

input:

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

output:

0 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 485 48...

result:

ok Accepted

Test #22:

score: 0
Accepted
time: 235ms
memory: 4164kb

input:

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

output:

0 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 199 19...

result:

ok Accepted

Test #23:

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

input:

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

output:

0 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 71...

result:

ok Accepted

Test #24:

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

input:

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

output:

0 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 72...

result:

ok Accepted

Test #25:

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

input:

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

output:

0 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 622 62...

result:

ok Accepted

Test #26:

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

input:

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

output:

0 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 39...

result:

ok Accepted

Test #27:

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

input:

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

output:

0 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 30...

result:

ok Accepted

Test #28:

score: 0
Accepted
time: 274ms
memory: 4172kb

input:

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

output:

0 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 19...

result:

ok Accepted

Test #29:

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

input:

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

output:

0 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 445 44...

result:

ok Accepted

Test #30:

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

input:

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

output:

0 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 264 26...

result:

ok Accepted

Test #31:

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

input:

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

output:

0 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 19...

result:

ok Accepted

Test #32:

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

input:

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

output:

0 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 28...

result:

ok Accepted

Test #33:

score: 0
Accepted
time: 265ms
memory: 4164kb

input:

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

output:

0 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 261 26...

result:

ok Accepted

Test #34:

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

input:

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

output:

0 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 740 74...

result:

ok Accepted

Test #35:

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

input:

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

output:

0 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 42...

result:

ok Accepted

Test #36:

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

input:

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

output:

0 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 89...

result:

ok Accepted

Test #37:

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

input:

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

output:

0 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 40...

result:

ok Accepted

Test #38:

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

input:

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

output:

0 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 4...

result:

ok Accepted

Test #39:

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

input:

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

output:

0 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 744 74...

result:

ok Accepted

Test #40:

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

input:

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

output:

0 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 374 37...

result:

ok Accepted

Test #41:

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

input:

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

output:

0 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 587 58...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed