QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#740688#9432. PermutationAllenJYLAC ✓306ms3932kbC++143.7kb2024-11-13 11:08:012024-11-13 11:08:02

Judging History

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

  • [2024-11-13 11:08:02]
  • 评测
  • 测评结果:AC
  • 用时:306ms
  • 内存:3932kb
  • [2024-11-13 11:08:01]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

// #define int long long
#define ls (p<<1)
#define rs (p<<1|1)
#define mid ((l+r)>>1)
#define all(_array) (_array).begin(),(_array).end()
#define msp(_array) memset(_array,0x3f,sizeof _array)
#define ms0(_array) memset(_array,0,sizeof _array)
#define msn(_array) memset(_array,-1,sizeof _array)
#define mc(_tar,_array) memcpy(_tar,_array,sizeof _tar)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define TAK cout<<"TAK"<<endl
#define NIE cout<<"NIE"<<endl
#define OK cerr<<"OK"<<endl
#define pii pair<int,int>
// #define endl '\n'

bool bg_memory;
mt19937 rnd(time(0));
int Case=1;
const int mod=1e9+7;
const int inf=2147483647;
const int bs=233;
const double eps=1e-6;
const int N=1e3+7,M=1e5+7;

template<class _t1,class _t2>inline void cmax(_t1 &a,_t2 b){a=a<b?b:a;}
template<class _t1,class _t2>inline void cmin(_t1 &a,_t2 b){a=a>b?b:a;}
inline int qp(int a,int b,int p=mod){int res=1;while(b){if(b&1)res=1ll*res*a%p;a=1ll*a*a%p;b>>=1;}return res;}
inline int sqrt(int x,int r){int l=0,ans=0;while(l<=r){if(1ll*mid*mid<=x) ans=mid,l=mid+1;else r=mid-1;}return ans;}

int n;
int id[N];
int ans[N],qu[N];
int T[N],Tot;
vector<int> v;
int ask(int l,int r,int a,int b){
    for(int i=r+1;i<=n;i++) qu[id[i]]=b;
    for(int i=1;i<=r;i++) qu[id[i]]=a;
    cout<<"0 ";
    for(int i=1;i<=n;i++) cout<<qu[i]<<" ";
    cout<<endl;
    int tmp=0;
    // for(int i=1;i<=n;i++) tmp+=(T[i]==qu[i]);
    // Tot++;
    cin>>tmp;
    return tmp;
}
void solve(int l,int r,vector<int> v){
    // cout<<l<<" "<<r<<endl;
    // for(int i:v) cout<<i<<" ";
    // cout<<endl<<tmp<<endl;
    shuffle(all(v),rnd);
    if(l==r) return ans[id[l]]=v.back(),void();
    vector<int> L,R,unk;
    for(int i:v){
        if(L.size()==mid-l+1){
            R.push_back(i);
            continue;
        }else if(R.size()==r-mid){
            L.push_back(i);
            continue;
        }
        if(!unk.size()){
            unk.push_back(i);
            continue;
        }
        int res=ask(l,mid,i,unk.back());
        if(res==2){
            L.push_back(i);
            for(int j:unk) R.push_back(j);
            unk.clear();
        }else if(res==0){
            R.push_back(i);
            for(int j:unk) L.push_back(j);
            unk.clear();
        }else unk.push_back(i);
    }
    // cout<<L.size()<<" "<<R.size()<<" "<<unk.size()<<endl;
    if(L.size()+unk.size()==mid-l+1) for(int j:unk) L.push_back(j);
    else for(int j:unk) R.push_back(j);
    // cout<<l<<" "<<r<<" "<<Tot<<endl;
    solve(l,mid,L);
    solve(mid+1,r,R);
}

void Main(){
    
    // n=1000;
    cin>>n;
    // for(int i=1;i<=n;i++) T[i]=i;
    // shuffle(T+1,T+n+1,rnd);
    for(int i=1;i<=n;i++) id[i]=i,v.push_back(i);
    shuffle(id+1,id+n+1,rnd);
    solve(1,n,v);
    cout<<"1 ";
    for(int i=1;i<=n;i++) cout<<ans[i]<<" ";
    // cout<<Tot<<endl;
    return;
}
string RdFile="";
bool en_memory;

signed main(){
    auto bg_clock=chrono::high_resolution_clock::now();
#ifdef ONLINE_JUDGE
    // freopen((RdFile+".in").c_str(),"r",stdin);
    // freopen((RdFile+".out").c_str(),"w",stdout);
#endif
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    // cout.tie(0);
    // cin>>Case;
    while(Case--) Main();
    auto en_clock=chrono::high_resolution_clock::now();
    auto duration_clock=chrono::duration_cast<chrono::microseconds>(en_clock-bg_clock);
    double duration_count=duration_clock.count()*0.001;
    double memory_used=(&en_memory-&bg_memory)/1024.0/1024;
    // cerr<<"Time:"<<duration_count<<"ms"<<endl;
    // cerr<<"Memory: "<<memory_used<<"MB"<<endl;
    return 0;
}

詳細信息

Test #1:

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

input:

5
1
2
0
0
2

output:

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

result:

ok Accepted

Test #2:

score: 0
Accepted
time: 288ms
memory: 3604kb

input:

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

output:

0 709 305 305 305 709 709 709 305 709 709 709 709 709 709 709 709 305 305 709 709 709 709 305 709 709 305 709 305 305 305 709 305 305 305 305 305 709 709 305 709 305 305 305 305 709 305 305 305 709 305 709 305 709 305 305 709 305 305 305 305 709 305 305 709 305 305 709 709 709 305 709 305 305 709 30...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1 

result:

ok Accepted

Test #4:

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

input:

2
0

output:

0 1 2 
1 2 1 

result:

ok Accepted

Test #5:

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

input:

3
0
2

output:

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

result:

ok Accepted

Test #6:

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

input:

4
2
2
0
2

output:

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

result:

ok Accepted

Test #7:

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

input:

6
1
0
2
1
0
0
2
2

output:

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

result:

ok Accepted

Test #8:

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

input:

7
2
1
0
2
1
2
2
0
2
0

output:

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

result:

ok Accepted

Test #9:

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

input:

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

output:

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

result:

ok Accepted

Test #10:

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

input:

9
2
2
2
2
2
2
0
2
0
2
2
0
2

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

score: 0
Accepted
time: 281ms
memory: 3748kb

input:

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

output:

0 405 372 372 372 405 372 405 372 372 372 372 372 405 372 372 372 405 372 372 372 372 405 405 372 372 405 372 405 405 405 372 405 405 405 372 372 405 372 405 372 372 372 405 372 405 405 372 405 405 405 372 372 405 372 405 372 372 405 405 405 372 405 405 372 405 405 405 405 405 372 372 405 405 405 37...

result:

ok Accepted

Test #18:

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

input:

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

output:

0 399 835 835 399 399 835 835 835 399 399 835 835 399 835 835 835 399 835 835 835 835 399 399 399 399 835 835 835 399 399 399 835 399 835 835 835 835 399 835 399 399 835 835 835 399 399 399 399 399 835 835 835 399 399 399 399 399 399 399 399 835 399 399 835 835 835 399 399 835 835 835 835 835 399 39...

result:

ok Accepted

Test #19:

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

input:

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

output:

0 547 547 547 547 969 547 547 547 969 547 547 969 547 969 547 547 969 547 969 547 969 969 969 969 969 547 547 969 969 547 547 547 969 969 969 969 969 547 547 969 969 547 547 547 547 547 547 547 547 547 969 547 969 969 547 969 547 547 969 969 547 547 969 969 969 969 969 547 547 969 547 969 547 547 96...

result:

ok Accepted

Test #20:

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

input:

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

output:

0 265 561 265 265 265 561 265 561 561 561 265 265 265 561 561 265 265 265 265 561 265 265 265 561 265 561 265 561 561 265 265 561 561 561 561 561 265 265 561 265 265 561 561 265 561 265 561 561 265 561 265 561 265 561 561 265 561 561 265 265 561 265 561 561 265 265 561 561 265 561 265 265 265 265 56...

result:

ok Accepted

Test #21:

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

input:

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

output:

0 118 118 118 279 279 279 279 118 279 279 279 118 279 118 279 279 118 118 279 118 279 118 279 118 279 279 279 279 279 279 279 279 279 118 279 279 279 118 118 279 118 279 118 279 118 279 279 118 279 279 279 118 118 118 118 118 279 279 118 118 118 279 279 279 279 279 118 118 279 118 279 118 118 118 11...

result:

ok Accepted

Test #22:

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

input:

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

output:

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

result:

ok Accepted

Test #23:

score: 0
Accepted
time: 288ms
memory: 3700kb

input:

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

output:

0 55 55 55 55 678 55 55 678 678 55 55 678 55 55 678 678 678 55 55 678 678 55 678 678 678 678 55 678 678 55 55 55 55 55 678 55 678 678 678 678 55 678 55 55 55 678 678 55 678 678 55 678 678 55 678 55 55 55 678 55 678 678 678 55 55 678 678 55 55 678 55 55 55 55 678 678 678 678 678 678 55 55 678 678 55 ...

result:

ok Accepted

Test #24:

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

input:

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

output:

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

result:

ok Accepted

Test #25:

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

input:

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

output:

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

result:

ok Accepted

Test #26:

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

input:

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

output:

0 281 281 281 281 263 281 281 281 263 281 281 263 263 281 263 263 263 263 263 281 281 281 263 263 281 281 263 281 263 263 281 263 281 281 281 281 263 263 281 281 263 263 263 281 263 263 263 263 281 281 263 281 281 281 281 281 263 281 281 281 263 263 263 281 281 263 281 281 281 281 263 263 263 281 28...

result:

ok Accepted

Test #27:

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

input:

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

output:

0 264 264 442 442 264 442 442 264 264 442 264 264 442 264 264 442 264 442 264 442 264 264 264 264 442 442 442 442 442 264 442 264 264 442 442 442 442 264 264 264 442 264 264 442 442 442 264 264 442 442 264 442 442 264 442 442 442 264 442 264 264 442 264 264 442 264 264 264 264 264 264 442 264 264 44...

result:

ok Accepted

Test #28:

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

input:

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

output:

0 300 655 300 300 300 300 655 655 655 300 655 300 655 300 655 300 655 655 655 300 655 300 655 655 300 655 655 300 655 300 655 655 300 655 655 300 300 300 655 655 655 655 655 655 300 300 300 300 655 655 655 300 300 300 655 655 655 655 300 655 655 655 300 655 655 655 300 655 655 300 655 655 655 300 65...

result:

ok Accepted

Test #29:

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

input:

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

output:

0 458 56 458 56 56 458 56 56 458 458 56 458 56 458 56 56 56 56 458 458 458 458 458 458 56 56 56 56 458 458 458 56 458 56 56 458 56 56 56 458 458 56 458 56 56 56 56 458 56 458 56 458 56 458 56 458 56 56 458 458 56 56 56 56 458 56 56 458 56 56 56 458 458 56 458 458 458 458 56 458 458 56 458 458 458 56...

result:

ok Accepted

Test #30:

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

input:

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

output:

0 592 592 592 592 289 289 289 289 592 289 289 289 289 592 289 289 289 289 592 289 592 289 592 289 592 592 592 289 289 592 592 592 592 592 289 289 289 592 592 592 592 592 289 289 289 592 592 592 289 592 592 592 592 592 289 289 289 289 289 289 592 592 592 289 592 592 592 289 592 289 289 289 289 592 59...

result:

ok Accepted

Test #31:

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

input:

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

output:

0 856 728 856 856 728 728 728 728 728 856 856 856 856 728 856 728 856 856 728 856 856 856 856 728 856 728 856 856 728 728 856 856 728 856 728 856 856 728 728 728 728 856 856 728 728 856 856 728 856 728 856 728 728 728 856 728 728 728 856 856 728 856 728 856 856 856 728 728 728 728 856 856 856 728 85...

result:

ok Accepted

Test #32:

score: 0
Accepted
time: 298ms
memory: 3700kb

input:

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

output:

0 263 263 316 263 263 263 316 263 263 316 316 316 263 263 316 316 263 263 316 263 316 263 263 316 316 263 316 316 316 316 263 263 263 316 263 316 316 316 316 316 263 316 263 263 316 316 316 263 316 316 316 316 263 263 316 263 263 316 316 316 316 263 263 263 316 263 263 316 316 316 263 316 316 316 31...

result:

ok Accepted

Test #33:

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

input:

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

output:

0 126 126 126 126 126 126 50 50 126 50 126 126 50 50 126 50 126 126 50 126 50 126 126 50 50 126 126 50 50 50 126 126 126 126 126 50 50 126 50 50 126 50 126 126 126 50 126 126 50 50 50 126 126 126 50 50 126 126 126 50 50 50 126 126 126 50 126 126 50 126 126 126 50 50 50 50 50 126 50 126 126 50 50 126...

result:

ok Accepted

Test #34:

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

input:

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

output:

0 379 379 938 379 938 938 938 938 938 938 379 379 379 938 379 938 938 379 379 379 379 379 379 379 938 379 938 938 379 379 938 938 379 379 938 379 379 938 379 379 938 379 379 379 938 379 938 379 379 379 379 379 938 379 379 938 938 379 938 379 379 938 379 379 938 379 938 938 379 379 938 938 938 379 37...

result:

ok Accepted

Test #35:

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

input:

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

output:

0 154 579 579 154 579 579 154 154 579 154 579 579 579 579 579 579 579 154 579 154 579 154 579 154 154 154 154 154 579 154 579 154 154 154 154 154 154 579 154 579 154 579 579 579 154 579 154 579 579 579 154 579 579 154 154 579 154 154 154 579 579 154 154 579 154 154 154 579 154 579 154 154 579 579 15...

result:

ok Accepted

Test #36:

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

input:

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

output:

0 294 294 844 294 844 294 294 294 844 844 844 844 294 294 294 844 294 294 294 844 294 844 844 294 844 844 844 844 294 844 844 844 294 844 844 844 294 294 294 844 294 844 294 844 844 294 294 844 844 294 844 844 294 294 844 844 844 294 844 294 294 844 844 294 844 844 844 294 294 844 294 844 294 844 29...

result:

ok Accepted

Test #37:

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

input:

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

output:

0 661 726 726 726 661 726 661 726 661 661 726 726 726 726 661 661 726 726 726 661 726 726 661 661 661 726 661 661 726 661 726 726 726 726 726 661 661 661 661 726 726 726 726 726 726 661 726 726 661 661 661 726 661 726 726 726 661 726 726 661 726 661 661 726 661 726 726 661 726 661 726 726 661 661 66...

result:

ok Accepted

Test #38:

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

input:

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

output:

0 115 533 533 533 533 115 115 115 115 533 533 533 533 533 115 533 115 115 533 533 115 115 533 533 115 533 115 115 533 115 115 115 533 115 533 115 533 533 115 533 115 533 115 533 533 115 533 533 115 533 115 115 533 115 115 533 115 533 115 533 115 533 533 533 533 115 115 533 533 115 115 115 115 533 53...

result:

ok Accepted

Test #39:

score: 0
Accepted
time: 305ms
memory: 3748kb

input:

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

output:

0 179 755 755 755 755 755 755 755 755 179 755 179 179 179 179 179 755 179 179 179 755 755 755 179 755 755 179 755 755 179 755 179 755 179 179 755 755 755 755 179 755 179 179 179 755 755 179 755 179 755 179 755 179 179 755 755 179 179 755 179 755 179 755 179 755 755 179 755 179 179 755 755 755 179 75...

result:

ok Accepted

Test #40:

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

input:

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

output:

0 48 48 908 908 48 48 908 48 48 908 48 908 908 908 908 48 908 908 48 908 908 908 48 908 908 48 908 908 908 908 48 48 48 48 908 908 908 48 908 48 908 48 908 48 48 908 48 48 908 48 48 48 908 908 908 48 908 48 48 48 48 908 908 48 908 48 48 908 48 908 48 48 48 48 48 48 48 48 908 908 48 908 908 48 908 90...

result:

ok Accepted

Test #41:

score: 0
Accepted
time: 271ms
memory: 3700kb

input:

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

output:

0 761 761 761 759 759 761 761 759 759 761 759 759 759 759 759 761 761 761 759 759 761 761 759 759 761 761 759 761 759 761 761 761 759 759 759 761 761 759 761 759 761 759 759 759 759 759 761 761 761 761 759 761 761 761 761 761 761 761 759 761 759 761 761 759 761 761 759 761 761 759 759 761 759 761 75...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed