QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#747351#9432. PermutationNahidameowAC ✓229ms4076kbC++203.5kb2024-11-14 16:58:082024-11-14 16:58:08

Judging History

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

  • [2024-11-14 16:58:08]
  • 评测
  • 测评结果:AC
  • 用时:229ms
  • 内存:4076kb
  • [2024-11-14 16:58:08]
  • 提交

answer

#include<bits/stdc++.h>
#define pd push_back
#define all(A) A.begin(),A.end()
#define lb lower_bound
#define ve std::vector
typedef long long ll;
typedef long long ll;
typedef __int128 Int;
typedef unsigned long long ul;
typedef long double LD;
bool FileIfstream(std::string name){
	std::ifstream f(name.c_str());
	return f.good();
}
namespace Math{
	ll QP(ll x,ll y,ll mod){ll ans=1;for(;y;y>>=1,x=x*x%mod)if(y&1)ans=ans*x%mod;return ans;}
	ll inv(ll x,ll mod){return QP(x,mod-2,mod);}
}
const int N=2e5+10;
const int mod=998244353;
namespace Grader{
	std::vector<int>S;
	int n;ve<int>P;
	int tot;
	void init(int _n){
		n=_n;P.resize(n+1);
		for(int i=1;i<=n;i++)std::cin>>P[i];
		tot=0;
	}
	void Get(std::vector<int>v){
		assert(S.empty());
		if(v.size()!=n+1){std::cout<<"size(n) is not ok\n";exit(0);}
		if(v[0]==0){
			tot++;
			int cnt=0;
			for(int i=1;i<=n;i++){
				if(v[i]<1||v[i]>n){
					std::cout<<"range(v) is not ok\n";
					for(int j=1;j<=n;j++)
						std::cout<<v[j]<<' ';					
					exit(0);
				}
				cnt+=v[i]==P[i];
			}
			S.pd(cnt);
		}else{
			for(int i=1;i<=n;i++)
				if(v[i]!=P[i]){
					std::cout<<"not ok\n";
					for(int j=1;j<=n;j++)
						std::cout<<v[j]<<' ';	
					exit(0);
				}
			std::cout<<"ok\n";
			std::cout<<"times: "<<tot<<'\n';
		}
		reverse(all(S));
	}
	int readInt(){
		assert(!S.empty());
		int x=S.back();
		S.pop_back();
		return x;
	}
	void putInt(int x){
		std::vector<int>P;
		P.pd(x);Get(P);
	}void putVec(std::vector<int>v){Get(v);}
}
std::mt19937 rnd(time(NULL));
int Grnd(int l,int r){return rnd()%(r-l+1)+l;}
void solve(){
	//don't forget to open long long
	int n;std::cin>>n;//Grader::init(n);
	if(n==1)return std::cout<<"1 1\n",std::cout.flush(),void(); 
	auto query=[&](ve<int>v)->int{
		v.insert(v.begin(),0);
		for(auto &p:v)std::cout<<p<<' ';std::cout<<'\n';
		std::cout.flush();
	//	Grader::putVec(v);
		int x;
	//	x=Grader::readInt();
		std::cin>>x;
		return x;
	};
	ve<int>ans(n+1);ans[0]=1;
//	int F=Grnd(1,n);int pos=0;
//	for(int i=1;i<=n;i++){
//		ve<int>v(n,(F==1)?2:1);v[i-1]=F;
//		if(query(v)==2){pos=i;break;}
//	}
	ve<int>vt;
	for(int i=1;i<=n;i++)vt.pd(i);
	auto calc=[&](int l,int r,ve<int>vt,auto self)->void{
		if(l==r)return ans[l]=vt[0],void();
		ve<int>L,R;auto mid=l+r>>1;
		ve<ve<int>>v;
		for(auto &p:vt)v.pd({p});
		shuffle(all(v),rnd);
		while(v.size()>1){
			ve<int>P1=v.back();v.pop_back();
			ve<int>P2=v.back();v.pop_back();
			ve<int>rv(n);
			for(int i=1;i<=mid;i++)rv[i-1]=P1[0];
			for(int i=mid+1;i<=n;i++)rv[i-1]=P2[0];
			int p=query(rv);
			if(p==0){
				for(auto &p:P1)R.pd(p);
				for(auto &p:P2)L.pd(p);
			}else if(p==2){
				for(auto &p:P1)L.pd(p);
				for(auto &p:P2)R.pd(p);
			}else{
				for(auto &p:P2)P1.pd(p);
				v.pd(P1);
			}
		}
		if(v.size()==1){
			if(L.size()!=mid-l+1)for(auto &p:v[0])
				L.pd(p);
			else for(auto &p:v[0])
				R.pd(p);
		}
		self(l,mid,L,self);
		self(mid+1,r,R,self);
	};
	calc(1,n,vt,calc);
	for(auto &p:ans)std::cout<<p<<' ';std::cout<<'\n';std::cout.flush();
	//Grader::putVec(ans);
}
int main(){
#ifndef ONLINE_JUDGE
	if(!FileIfstream("IO.in")){
		freopen("IO.in","w",stdout);
		return 0;
	}
	freopen("IO.in","r",stdin);
	freopen("IO.out","w",stdout);
#endif
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);
	int T=1;
	//std::cin>>T;
	while(T--)solve();

#ifndef ONLINE_JUDGE
	std::cerr<<std::fixed<<std::setprecision(10)<<1.0*clock()/CLOCKS_PER_SEC<<'\n';
#endif

	return 0;
}






详细

Test #1:

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

input:

5
1
0
1
0
2
0

output:

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

result:

ok Accepted

Test #2:

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

input:

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

output:

0 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 838 83...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1

result:

ok Accepted

Test #4:

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

input:

2
0

output:

0 1 2 
1 2 1 

result:

ok Accepted

Test #5:

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

input:

3
0
0

output:

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

result:

ok Accepted

Test #6:

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

input:

4
2
0
2
2

output:

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

result:

ok Accepted

Test #7:

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

input:

6
1
1
2
1
1
2
0
0
2

output:

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

input:

7
1
2
2
2
0
2
0
2
1
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 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 5 5 5 5 5 5 6 
0 5 5 5 5 5 5 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: 3932kb

input:

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

output:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

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

input:

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

output:

0 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 13...

result:

ok Accepted

Test #18:

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

input:

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

output:

0 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 637 63...

result:

ok Accepted

Test #19:

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

input:

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

output:

0 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 6...

result:

ok Accepted

Test #20:

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

input:

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

output:

0 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 44...

result:

ok Accepted

Test #21:

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

input:

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

output:

0 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 454 45...

result:

ok Accepted

Test #22:

score: 0
Accepted
time: 193ms
memory: 4064kb

input:

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

output:

0 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 355 35...

result:

ok Accepted

Test #23:

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

input:

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

output:

0 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 20...

result:

ok Accepted

Test #24:

score: 0
Accepted
time: 177ms
memory: 3716kb

input:

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

output:

0 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 803 80...

result:

ok Accepted

Test #25:

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

input:

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

output:

0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2...

result:

ok Accepted

Test #26:

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

input:

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

output:

0 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 7...

result:

ok Accepted

Test #27:

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

input:

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

output:

0 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 618 61...

result:

ok Accepted

Test #28:

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

input:

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

output:

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

result:

ok Accepted

Test #29:

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

input:

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

output:

0 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 776 77...

result:

ok Accepted

Test #30:

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

input:

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

output:

0 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 83...

result:

ok Accepted

Test #31:

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

input:

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

output:

0 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 212 21...

result:

ok Accepted

Test #32:

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

input:

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

output:

0 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 2...

result:

ok Accepted

Test #33:

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

input:

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

output:

0 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 20...

result:

ok Accepted

Test #34:

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

input:

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

output:

0 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 932 93...

result:

ok Accepted

Test #35:

score: 0
Accepted
time: 229ms
memory: 3780kb

input:

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

output:

0 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 636 63...

result:

ok Accepted

Test #36:

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

input:

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

output:

0 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 66...

result:

ok Accepted

Test #37:

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

input:

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

output:

0 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 85...

result:

ok Accepted

Test #38:

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

input:

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

output:

0 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 915 91...

result:

ok Accepted

Test #39:

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

input:

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

output:

0 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 569 56...

result:

ok Accepted

Test #40:

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

input:

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

output:

0 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 82...

result:

ok Accepted

Test #41:

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

input:

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

output:

0 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 684 68...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed