QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#354051#5312. Levenshtein DistanceNahidameowAC ✓2249ms23372kbC++2017.6kb2024-03-14 21:02:032024-03-14 21:02:05

Judging History

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

  • [2024-03-14 21:02:05]
  • 评测
  • 测评结果:AC
  • 用时:2249ms
  • 内存:23372kb
  • [2024-03-14 21:02:03]
  • 提交

answer

#include<bits/stdc++.h>
//=========================================================
typedef long long ll;
typedef __int128 Int;
typedef unsigned long long ul;
typedef long double LD;
#define pd push_back
#define all(x) x.begin(),x.end()
#define allA(x,l,r) x+l,x+r+1
#define mpr std::make_pair
#define ve std::vector
#define mpre(v) v.insert(v.begin(),0)
#define lb lower_bound
//=========================================================
namespace Balance_tree{
	struct Mes{
		Mes(){}
		friend Mes operator + (Mes A,Mes B){
			Mes ans;
			return ans;
		}
	};
	const int N=2e5+10;
	std::mt19937 rnd(time(NULL));
	struct Mes_BLT{
		struct node{int l,r;ll val;int key,sz;Mes rv,v;}tr[5];//don't forget to promote it
		int rot,cnt=0;
		std::vector<int> bin;
		void pushup(int rt){tr[rt].sz=tr[tr[rt].l].sz+tr[tr[rt].r].sz+1;
			if(tr[rt].l&&tr[rt].r)tr[rt].rv=tr[tr[rt].l].rv+tr[rt].v+tr[tr[rt].r].rv;
			else if(tr[rt].l)tr[rt].rv=tr[tr[rt].l].rv+tr[rt].v;
			else if(tr[rt].r)tr[rt].rv=tr[rt].v+tr[tr[rt].r].v;}
		int newid(){
			if(bin.empty())return ++cnt;
			int x=bin.back();bin.pop_back();
			return x;
		}void split(int rt,ll val,int &x,int &y){
			if(!rt)return x=y=0,void();
			if(tr[rt].val<=val)x=rt,split(tr[rt].r,val,tr[rt].r,y);
			else y=rt,split(tr[rt].l,val,x,tr[rt].l);
			pushup(rt);
		}int merge(int x,int y){
			if(!x||!y)return x|y;
			if(tr[x].key<=tr[y].key)
				return tr[x].r=merge(tr[x].r,y),pushup(x),x;
			else return tr[y].l=merge(x,tr[y].l),pushup(y),y;
		}int build(int val,Mes P){int id=newid();return tr[id]={0,0,val,int(rnd()),1,P,P},id;}
		void insert(ll val,Mes P){
			int x,y;split(rot,val,x,y);
			rot=merge(merge(x,build(val,P)),y);
		}void del(ll val){
			int x,y,z;split(rot,val,x,z);
			split(x,val-1,x,y);bin.pd(y);
			rot=merge(merge(x,merge(tr[y].l,tr[y].r)),z);
		}Mes query(ll l,ll r){
			int x,y,z;split(rot,r,x,z);
			split(x,l-1,x,y);
			Mes ans=tr[y].rv;
			rot=merge(merge(x,y),z);
			return ans;
		}
		void clear(){for(int i=1;i<=cnt;i++)tr[i]={0,0,0,0,0,Mes(),Mes()};cnt=rot=0;bin.clear();}
	};
	struct Basic_BLT{
		struct node{int l,r;ll val;int key,sz;}tr[5];//don't forget to promote it
		int rot,cnt=0;
		std::vector<int> bin;
		void pushup(int rt){tr[rt].sz=tr[tr[rt].l].sz+tr[tr[rt].r].sz+1;}
		int newid(){
			if(bin.empty())return ++cnt;
			int x=bin.back();bin.pop_back();
			return x;
		}void split(int rt,int val,int &x,int &y){
			if(!rt)return x=y=0,void();
			if(tr[rt].val<=val)x=rt,split(tr[rt].r,val,tr[rt].r,y);
			else y=rt,split(tr[rt].l,val,x,tr[rt].l);
			pushup(rt);
		}int merge(int x,int y){
			if(!x||!y)return x|y;
			if(tr[x].key<=tr[y].key)
				return tr[x].r=merge(tr[x].r,y),pushup(x),x;
			else return tr[y].l=merge(x,tr[y].l),pushup(y),y;
		}int build(ll val){int id=newid();return tr[id]={0,0,val,int(rnd()),1},id;}
		void insert(ll val){
			int x,y;split(rot,val,x,y);
			rot=merge(merge(x,build(val)),y);
		}void del(ll val){
			int x,y,z;split(rot,val,x,z);
			split(x,val-1,x,y);bin.pd(y);
			rot=merge(merge(x,merge(tr[y].l,tr[y].r)),z);
		}int Get_rank(int rt,int k){
			if(k<=tr[tr[rt].l].sz)return Get_rank(tr[rt].l,k);
			if(k==tr[tr[rt].l].sz+1)return rt;
			return Get_rank(tr[rt].r,k-tr[tr[rt].l].sz-1);
		}
		void clear(){for(int i=1;i<=cnt;i++)tr[i]={0,0,0,0,0};cnt=rot=0;bin.clear();}
	};
}
namespace segment_tree{
	const int N=2e5+10;
	template<typename M,typename T> struct sg_tree{
		struct node{M Mes;T Tag;int l,r;}tr[5];
		int rot;int cnt;
		void init(){for(int i=1;i<=cnt;i++)tr[i].Mes=M(),tr[i].Tag=T(),tr[i].l=tr[i].r=0;rot=cnt=0;}
		void pushup(int rt){
			tr[rt].Mes=M();
			if(tr[rt].l&&tr[rt].r)tr[rt].Mes=tr[tr[rt].l].Mes+tr[tr[rt].r].Mes;
			else if(tr[rt].l)tr[rt].Mes=tr[tr[rt].l].Mes;
			else if(tr[rt].r)tr[rt].Mes=tr[tr[rt].r].Mes;
		}
		void addson(int rt,T x){tr[rt].Mes=tr[rt].Mes+x;tr[rt].Tag=tr[rt].Tag+x;}
		void pushdown(int rt){
			if(tr[rt].Tag==T())return;
			if(tr[rt].l)addson(tr[rt].l,tr[rt].Tag);
			if(tr[rt].r)addson(tr[rt].r,tr[rt].Tag);
			tr[rt].Tag=T();
		}
		void build(int &rt,int l,int r,std::vector<M> &A){
			if(!rt)rt=++cnt;
			if(l==r)return tr[rt].Mes=A[l],void();
			auto mid=l+r>>1;
			build(tr[rt].l,l,mid,A);build(tr[rt].r,mid+1,r,A);
			pushup(rt);
		}
		void change_Seq(int &rt,int l,int r,int x,int y,T P){
			if(x>y)return;
			if(!rt)rt=++cnt,tr[rt].Mes=M(),tr[rt].Tag=T();
			if(x<=l&&r<=y)return addson(rt,P);
			auto mid=l+r>>1;pushdown(rt);
			if(x<=mid)change_Seq(tr[rt].l,l,mid,x,y,P);
			if(y>mid)change_Seq(tr[rt].r,mid+1,r,x,y,P);
			pushup(rt);
		}
		void change_p(int &rt,int l,int r,int x,T P){
			if(!rt)rt=++cnt,tr[rt].Mes=M(),tr[rt].Tag=T();
			if(l==r)return addson(rt,P);
			auto mid=l+r>>1;pushdown(rt);
			(x<=mid)?change_p(tr[rt].l,l,mid,x,P):change_p(tr[rt].r,mid+1,r,x,P);
			pushup(rt);
		}
		M query(int rt,int l,int r,int x,int y){
			if(!rt||x>y)return M();
			if(x<=l&&r<=y)return tr[rt].Mes;
			auto mid=l+r>>1;pushdown(rt);
			if(x<=mid&&y>mid)return query(tr[rt].l,l,mid,x,y)+query(tr[rt].r,mid+1,r,x,y);
			if(x<=mid)return query(tr[rt].l,l,mid,x,y);
			if(y>mid)return query(tr[rt].r,mid+1,r,x,y);
			assert(false);
		}
		void build(int l,int r,std::vector<M> &A){build(rot,l,r,A);}
		void change_Seq(int l,int r,int x,int y,T P){
			change_Seq(rot,l,r,x,y,P);}
		void change_p(int l,int r,int x,T P){
			change_p(rot,l,r,x,P);}
		M query(int l,int r,int x,int y){
			return query(rot,l,r,x,y);}
	};
	struct Mes{
		Mes(){}
		Mes(ll _S,int _l,int _r){}
		Mes operator + (Mes P){
			Mes ans=Mes();
			return ans;
		}
	};
	struct Tag{
		Tag(){}
		Tag operator + (Tag P){
			Tag ans=Tag();
			return ans;
		}
		bool operator == (Tag P){return true!=false;}
	};
	Mes operator + (Mes A,Tag B){return A;}
}
namespace Fenwick_Tree{
	const int N=2e5+10;
	struct FwT{
		ll tr[5];int u;
		void init(int _u){
			u=_u;
			for(int i=0;i<=u;i++)tr[i]=0;}
		void add(int x,ll y){for(;x<=u;x+=(x&-x))tr[x]+=y;}
		ll query(int x){ll ans=0;for(;x;x^=(x&-x))ans+=tr[x];return ans;}
		ll query(int l,int r){if(l>r)return 0;return query(r)-query(l-1);}
	};
}
//=========================================================
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 QA(ll x,ll y,ll mod){ll ans=0;for(;y;y>>=1,x=(x<<1)%mod)if(y&1)ans=(ans+x)%mod;return ans;}
	ll inv(ll x,ll mod){return QP(x,mod-2,mod);}
}
typedef unsigned U;
const int M=998244353;
struct ModInt{
	static constexpr U mod=M;
	U val;
	constexpr ModInt():val(0U){}
	constexpr ModInt(U _val):val(_val){}
	constexpr ModInt(int _val):val((_val%int(mod)+int(mod))%int(mod)){}
	constexpr ModInt(ll _val):val((_val%ll(mod)+ll(mod))%ll(mod)){}
	ModInt(const ModInt &P):val(P.val){}
	inline ModInt operator +(ModInt p){return ModInt(int(val)+int(p.val));}
	inline ModInt operator -(ModInt p){return ModInt(int(val)-int(p.val));}
	inline ModInt operator *(ModInt p){return ModInt(1ll*val*p.val);}
	inline ModInt QP(ll y){
		if(y<0)return inv().QP(-y);
		ModInt A=(*this),B=1U;
		for(;y;A=A*A,y>>=1)if(y&1)B=B*A;
		return B;
	}inline ModInt inv(){return QP(mod-2);}
	inline ModInt operator /(ModInt p){return (*this)*p.inv();}
	inline ModInt operator ^(ModInt p){return QP(p.val);}
	template<typename T>
	inline ModInt operator ^(T p){return QP(p);}

	template<typename T>
	inline ModInt operator +(T p){return (*this)+ModInt(p);}
	template<typename T>
	inline ModInt operator -(T p){return (*this)-ModInt(p);}
	template<typename T>
	inline ModInt operator *(T p){return (*this)*ModInt(p);}
	template<typename T>
	inline ModInt operator /(T p){return (*this)/ModInt(p);}

	inline ModInt operator +(){return (*this);}
	inline ModInt operator -(){return ModInt(0)-(*this);}

	template<typename T>
	inline friend ModInt operator +(T A,ModInt P){return ModInt(A)+P;}
	template<typename T>
	inline friend ModInt operator -(T A,ModInt P){return ModInt(A)-P;}
	template<typename T>
	inline friend ModInt operator *(T A,ModInt P){return ModInt(A)*P;}
	template<typename T>
	inline friend ModInt operator /(T A,ModInt P){return ModInt(A)/P;}

	inline void operator --(){val=(!val?mod-1:val-1);}
	inline void operator ++(){val=(val==mod-1?0:val+1);}

	inline void operator +=(ModInt P){(*this)=(*this)+P;}
	inline void operator -=(ModInt P){(*this)=(*this)-P;}
	inline void operator *=(ModInt P){(*this)=(*this)*P;}
	inline void operator /=(ModInt P){(*this)=(*this)/P;}

	template<typename T>
	inline void operator +=(T P){return (*this)=(*this)+ModInt(P);}
	template<typename T>
	inline void operator -=(T P){return (*this)=(*this)-ModInt(P);}
	template<typename T>
	inline void operator *=(T P){return (*this)=(*this)*ModInt(P);}
	template<typename T>
	inline void operator /=(T P){return (*this)=(*this)/ModInt(P);}
	template<typename T>
	inline void operator ^=(T P){return (*this)=(*this)^P;}

	U key(){return val;}
	inline bool operator == (ModInt P){return P.val==val;}
	inline bool operator != (ModInt P){return !((*this)==P);}

};
//=========================================================
namespace IO{
	const double eps=1e-8;
	const int BUFSIZE=1<<20;
	char ibuf[BUFSIZE],*is=ibuf,*it=ibuf;
	char tmp[BUFSIZE];int cnt=0;
	inline char getch(){if(is==it)it=(is=ibuf)+fread(ibuf,1,BUFSIZE,stdin);return is==it?EOF:*is++;}
	int readInt(){int x=0,y=0;char c=0;while(!isdigit(c))y|=c=='-',c=getch();while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getch();return !y?x:-x;}
	ll readLL(){ll x=0,y=0;char c=0;while(!isdigit(c))y|=c=='-',c=getch();while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getch();return !y?x:-x;}
	Int readInt128(){Int x=0;int y=0;char c=0;while(!isdigit(c))y|=c=='-',c=getch();while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getch();return !y?x:-x;}
	char readChar(){char c=0;while(!c||c==' '||c=='\n')c=getch();return c;}
	std::string readString(){std::string S;char c=0;while(!c||c==' '||c=='\n')c=getch();while(c!=' '&&c!='\n')S.pd(c),c=getch();return S;}
	LD readDouble(){LD x=0,d=1;int y=0;char c=0;while(!isdigit(c))y|=c=='-',c=getch();int cnt=0;bool flg=false;while(isdigit(c)){
		x=x*10+(c^48),flg|=(c^48),cnt+=flg,c=getch();if(cnt>=12)goto flg;}if(c=='.'){c=getch();while(isdigit(c)){d*=10,x+=(c^48)/d;flg|=(c^48),cnt+=flg;
		if(cnt>=12)goto flg;c=getch();}}flg:;return !y?x:-x;}
	ul readUll(){ul x=0;char c=0;while(!isdigit(c))c=getch();while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getch();return x;}

	void flush(){fwrite(tmp,1,cnt,stdout);cnt=0;}
	void putch(char c){tmp[cnt++]=c;if(cnt==BUFSIZE)flush();}
	void putint(int x){char Q[10];int tp=0;if(x<0)putch('-'),x=-x;if(x==0)putch('0');while(x)Q[tp++]=(x%10+'0'),x/=10;while(tp--)putch(Q[tp]);}
	void putInt128(Int x){char Q[45];int tp=0;if(x<0)putch('-'),x=-x;if(x==0)putch('0');while(x)Q[tp++]=(x%10+'0'),x/=10;while(tp--)putch(Q[tp]);}
	void putLL(ll x){char Q[20];int tp=0;if(x<0)putch('-'),x=-x;if(x==0)putch('0');while(x)Q[tp++]=(x%10+'0'),x/=10;while(tp--)putch(Q[tp]);}
	void putString(std::string x){for(auto p:x)putch(p);}
	void putDouble(LD x){if(x<0)x=-x,putch('-');if(fabs(x)<=eps)return putch(0);bool flg=false;LD d=1e10;LD l=std::min(LD(1e-10),1.0/std::max(LD(1),x));
		while(d>=l){if(d<=1){if(ll(x/d+d*1e-2)%10>0||flg)putch(ll(x/d+d*1e-2)%10+'0'),flg=true;}else{if(ll(x/d)%10>0||flg)putch(ll(x/d)%10+'0'),flg=true;
		}x-=ll(x/d+eps)*d; if(d==1){if(!flg)putch('0');putch('.');}d/=10;}}
	void putUll(ul x){char Q[25];int tp=0;if(!x)putch('0');while(x)Q[tp++]=(x%10+'0'),x/=10;while(tp--)putch(Q[tp]);}

	struct Basic{
		Basic &operator>>(int &A){A=IO::readInt();return (*this);}
		Basic &operator>>(ll &A){A=IO::readLL();return (*this);}
		Basic &operator>>(Int &A){A=IO::readInt128();return (*this);}
		Basic &operator>>(char &A){A=IO::readChar();return (*this);}
		Basic &operator>>(std::string &A){A=IO::readString();return (*this);}
		Basic &operator>>(double &A){A=IO::readDouble();return (*this);}
		Basic &operator>>(LD &A){A=IO::readDouble();return (*this);}
		Basic &operator>>(float &A){A=IO::readDouble();return (*this);}
		template<typename T1,typename T2>
		Basic &operator>>(std::pair<T1,T2>&v){(*this)>>v.first>>v.second;return (*this);}
		template<typename T,int d>
		Basic &operator>>(std::array<T,d> &v){for(auto &p:v)(*this)>>p;return (*this);}
		template<typename T>
		Basic &operator>>(std::vector<T> &v){for(auto &p:v)(*this)>>p;return (*this);}
		Basic &operator>>(ul &v){v=readUll();return (*this);}

		Basic &operator<<(const int &A){putint(A);return (*this);}
		Basic &operator<<(const char &A){putch(A);return (*this);}
		Basic &operator<<(const ll &A){putLL(A);return (*this);}
		Basic &operator<<(const Int &A){putInt128(A);return (*this);}
		Basic &operator<<(const std::string &A){putString(A);return (*this);}
		Basic &operator<<(const LD &A){putDouble(A);return (*this);}
		Basic &operator<<(const double &A){putDouble(A);return (*this);}
		Basic &operator<<(const float &A){putDouble(A);return (*this);}
		template<typename T>
		Basic &operator<<(const std::vector<T> &v){for(int i=0;i<v.size();i++)(*this)<<v[i]<<(v.size()==i+1?'\n':' ');return (*this);}
		Basic &operator<<(const ul &A){putUll(A);return (*this);}

		void Flush(){flush();}
	}cin,cout;
}
//=========================================================
namespace Grader{
	std::vector<int>S;
	void Get(std::vector<int>v){
		assert(S.empty());

		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);}
}
//=========================================================
bool FileIfstream(std::string name){
	std::ifstream f(name.c_str());
	return f.good();
}
//=========================================================
//const int mod=998244353;
//int add(int x,int y){x+=y;if(x>=mod)x-=mod;if(x<0)x+=mod;return x;}
//int mul(int x,int y){return 1ll*x*y%mod;}
//void add(int &x,int y){x+=y;if(x>=mod)x-=mod;if(x<0)x+=mod;}
const int N=2e5+10;
struct Suffix_Array{
	int c[N],n;
	int SA[N],rk[N],ork[N<<1],key[N],id[N],cnt[N];
	void init(std::string S,int _n){
		n=_n;
		for(int i=1;i<=n;i++)c[i]=S[i];
	}void GetSA(){
		int m=127,pos=0;
		auto add=[&](int *rk,int *t)->void{
			for(int i=1;i<=n;i++)++cnt[rk[i]=t[id[i]]];};
		auto suf=[&]()->void{
			for(int i=1;i<=m;i++)cnt[i]+=cnt[i-1];};
		auto make=[&](int *rk)->void{
			for(int i=n;i;i--)SA[cnt[rk[i]]--]=id[i];};
		for(int i=1;i<=n;i++)id[i]=i;
		add(rk,c);suf();make(rk);
		for(int p=1;;p<<=1,m=pos,pos=0){
			for(int i=n;i>n-p;i--)id[++pos]=i;
			for(int i=1;i<=n;i++)if(SA[i]>p)id[++pos]=SA[i]-p;
			memset(cnt,0,sizeof(cnt));
			add(key,rk);suf();make(key);
			memcpy(ork+1,rk+1,n*sizeof(int));
			auto check=[&](int x,int y)->bool{
				return ork[x]==ork[y]&&
					ork[x+p]==ork[y+p];};
			pos=0;
			for(int i=1;i<=n;i++)
				rk[SA[i]]=check(SA[i],SA[i-1])?pos:++pos;
			if(pos==n)break; 
		}
	}int H[N];
	void makeheight(){
		for(int i=1;i<=n;i++)rk[SA[i]]=i;
		for(int i=1,k=0;i<=n;i++){
			if(!rk[i])continue;
			if(k)--k;while(c[i+k]==c[SA[rk[i]-1]+k])++k;
			H[rk[i]]=k;
		}
	}int st[30][N],LOG2[N];
	void build(){
		for(int i=1;i<=n;i++)st[0][i]=H[i];
		for(int i=2;i<=n;i++)LOG2[i]=LOG2[i>>1]+1;
		for(int j=1;j<=20;j++)
			for(int i=1;i+(1<<j)-1<=n;i++)
				st[j][i]=std::min(st[j-1][i],st[j-1][i+(1<<j-1)]);
	}int query(int l,int r){
		int k=LOG2[r-l+1];
		return std::min(st[k][l],st[k][r-(1<<k)+1]);
	}int LCP(int x,int y){
		if(!(x<=n&&y<=n&&x>=1&&y>=1))return 0;
		int p1=rk[x],p2=rk[y];
		if(p1==p2)return n-p1+1;
		if(p1>p2)std::swap(p1,p2);++p1;
		return query(p1,p2);
	}
}SA;
#define F(x,y) f[x][y+k]
void solve(){
	//don't forget to open long long;
	int k;std::cin>>k;
	std::string S,T;
	IO::cin>>S>>T;S.pd('#');T.pd('$');
	int n=S.size(),m=T.size();
	//IO::cout<<n<<'\n'<<'m;
	SA.init(" "+S+T,n+m);n--;m--;
	SA.GetSA();
	SA.makeheight();
	SA.build();
	std::queue<std::pair<int,int>>q;
	ve<int>ans(k+1);
	ve<int>dis(m+1);
	auto check=[&](int x,int y)->bool{return y<=x&&-x<=y&&x<=k;};
	for(int L=0;L<m;L++){
		ve<ve<int>>f(k+1,ve<int>(k*2+1,-1));
		q.push({0,0});
		//auto F=[&](int x,int y)->int&{assert(x<=k&&y+k<=2*k&&x>=0&&y+k>=0);return f[x][y+k];};
		F(0,0)=0;
		while(!q.empty()){
			auto x=q.front().first,y=q.front().second;q.pop();
			if(F(x,y)+1<=n)F(x,y)=F(x,y)+SA.LCP(F(x,y)+1,(n+1)+L+F(x,y)+y+1);
		//	std::cout<<x<<' '<<y<<' '<<F(x,y)<<'\n';
			if(check(x+1,y-1)){
				if(F(x+1,y-1)==-1)q.push({x+1,y-1});
				F(x+1,y-1)=std::max(F(x+1,y-1),F(x,y)+1);
			}if(check(x+1,y)){
				if(F(x+1,y)==-1)q.push({x+1,y});
				F(x+1,y)=std::max(F(x+1,y),F(x,y)+1);
			}if(check(x+1,y+1)){
				if(F(x+1,y+1)==-1)q.push({x+1,y+1});
				F(x+1,y+1)=std::max(F(x+1,y+1),F(x,y));
			}
		}
	//	for(int i=0;i<=k;i++)for(int j=-i;j<=i;j++)std::cout<<F(i,j)<<' ';std::cout<<'\n';
	//	for(int i=0;i<=k;i++)
	//		for(int j=-i;j<=i;j++)
	//			IO::cout<<F(i,j)<<'\n';
		int l=std::max(L+1,L+n-k),r=std::min(m,L+n+k);
		if(l>r)continue;
		assert(l<=m&&r<=m);
		for(int i=l;i<=r;i++)dis[i]=k+1;
		//auto min=[&](int x,int y)->int{return x<y?x:y;};
		for(int i=0;i<=k;i++)
			for(int j=-i;j<=i;j++)
				if(F(i,j)>=n&&L+n+j>=0)
					dis[std::min(m,L+n+j)]=std::min(dis[std::min(m,L+n+j)],i);
		for(int i=l;i<=r;i++)
			if(dis[i]<=k)
				ans[dis[i]]++;
	}
	for(int i=0;i<=k;i++)
		IO::cout<<ans[i]<<'\n';
}
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;
	while(T--)solve();

	IO::cout.Flush();
	return 0;
}











Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
aaa
aabbaab

output:

0
5
15
7
1

result:

ok 5 number(s): "0 5 15 7 1"

Test #2:

score: 0
Accepted
time: 908ms
memory: 13240kb

input:

30
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 31 numbers

Test #3:

score: 0
Accepted
time: 1126ms
memory: 13096kb

input:

30
BBAAABAABBBA
ABBABBBBAABAAAABABBBAABAABBAABAAAAAABAABABBAAAABAAAAABABAABAABBABBAAAABBBBAABBABAAABAABAABBBBBABBABABBBBABBBBAAABBABABBBBAAABBBBAAAABABABABABABABAAABBBBBAABAABAABBAABBBAABBBBBBBABAABAABAABABAABAAABAABBBAABABBABBAAABAAAABABABBABBBAAABBBAAAABBBBABABABAABAABBBBBBBBBAABBBABABBBABAABBABBA...

output:

17
662
8230
50302
166666
310121
345469
280387
227200
209178
203013
198561
105117
102147
99771
97730
96058
94730
93633
92720
92060
91525
91143
90831
90585
90419
90288
90200
90120
90068
90035

result:

ok 31 numbers

Test #4:

score: 0
Accepted
time: 1428ms
memory: 13448kb

input:

30
AAABBAAAAAAAAAAAAABAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAABAAAAABAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABABAAAABAAAABAAAABAAAAABAAAAAABAAAAAAAAABAAABAAABBAAAAAAAAAAAAAAAABAABAAABAAAAAAAAAAAAABAAAAAAAAAAAAAAAABAAABBAAAAAAAAAAAAAAAAAAAAAAAAAABAABAABABAAAAAAAAAAAAAAA...

output:

0
0
0
0
1
28
263
1410
6434
22523
56017
115080
189633
263874
316906
339254
332825
312943
286470
263283
246310
235032
227182
221294
216978
213734
211178
208848
206945
205393
204279

result:

ok 31 numbers

Test #5:

score: 0
Accepted
time: 1160ms
memory: 13200kb

input:

30
ABABAABAAABAAAA
AABBABABBBBBAAABABAABBAAABBBAABABBBABABABABABBABBBAAAAABBAAABBABABABABABBAAABBAAABAAABBBBBBBAABABBBAAAAABAABBBABBABBBABBBABABAABABBBAAABBABBAAABBBBBBBAABAABABAAAAAABBAABAAABBBAABBAABBAABBABABAAAAAAAABBBBBAAABABABBABAAAAABAABAABAABAABAAABABBABBBABAAABBBABABAABAABBBAABABBAABBAAAABAB...

output:

2
125
1938
15793
70756
178090
282937
325020
310617
277899
244094
217672
206966
202456
198644
105535
102767
100355
98411
96655
95310
94124
93217
92487
91872
91414
91039
90741
90555
90397
90276

result:

ok 31 numbers

Test #6:

score: 0
Accepted
time: 1263ms
memory: 13308kb

input:

30
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

output:

0
0
0
0
1
91
1082
14598
58877
123681
212928
258264
253856
277926
265254
243456
217809
198008
190004
184665
184470
183593
183524
183406
183335
183255
183185
183142
183078
182991
182922

result:

ok 31 numbers

Test #7:

score: 0
Accepted
time: 1112ms
memory: 13392kb

input:

30
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAABABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

output:

1
460
44032
126686
201431
222795
213509
199190
187254
184699
184159
183907
183818
183558
183500
183466
183412
183393
183343
183299
183275
183236
183163
183127
183105
183056
183010
182971
182910
182719
182437

result:

ok 31 numbers

Test #8:

score: 0
Accepted
time: 1143ms
memory: 13324kb

input:

30
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

output:

29
25121
100687
175758
199099
210112
187931
180903
178707
178497
178494
178497
178495
178496
178492
178492
178492
178491
178490
178491
178490
178490
178492
178489
178489
178488
178487
178487
178487
178488
178487

result:

ok 31 numbers

Test #9:

score: 0
Accepted
time: 1092ms
memory: 13536kb

input:

30
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

output:

17
12879
77552
170649
187824
198210
200962
189247
181730
180843
178608
178607
178607
178605
178599
178599
178599
178596
178595
178592
178594
178595
178593
178594
178593
178595
178593
178593
178594
178593
178591

result:

ok 31 numbers

Test #10:

score: 0
Accepted
time: 1191ms
memory: 14336kb

input:

30
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

output:

0
0
0
0
73
320
52858
125690
177498
270124
217932
192611
177148
228465
180709
166240
162360
162360
162359
162359
162359
162359
162358
162358
162359
162357
162357
162357
162357
162358
162358

result:

ok 31 numbers

Test #11:

score: 0
Accepted
time: 1254ms
memory: 13136kb

input:

30
ABBABABABAAABAAAAAAABAAABBAAAA
BABBABBBAAABBAAAAABBBBBAAAABAAAAAABBAABAAAABAAABAAAAAAAABAAABAABAABAABBBAAAABAAAABABBABBAAABABAAAAAAAABAABBAAAAAABABAAAAABABAAAAAAABAAAAAAAABAAABBBAAAAABAABAABAAAAABAAAAAAAAAAAABABAAAABABAAAABAABBAAAAABBAAABABBBBBBAABABAAAAABABBBAABABBAAAABAAAAABABABBAAAAAAAABABBBAB...

output:

0
0
1
38
617
4567
22647
76780
180046
296249
362349
361655
325883
289074
263906
246552
233312
221488
212319
205320
200921
198057
196229
194923
193749
192649
191581
190728
189773
188925
98116

result:

ok 31 numbers

Test #12:

score: 0
Accepted
time: 1231ms
memory: 14184kb

input:

30
Y3YYY
wwwwwwwYYwwwww3ww3w33Yww3wYY3w3w33w3Y3YY33wYwY33wwYwY33Y3w3wwwY333ww333Ywww3w3Y33wwYw3YYwY3Y3w33YwwwwwYYYw3YYYYYYww3w3333Yw3Y3wY3wYw3w3w3Y3w33YY33YwwY3Y3wY33w3333Yw333wYYw3Yw33w3YwYYYYYwwwwY3wwYYYYY33Y3YwYY3Yw3www3Ywww333w3YYY333YY3Y3333Y3Y33ww33333wwYY3YYYww3YYYYYYwwYYYwwYY33Y33wYY3w3wY3w3...

output:

412
9896
68598
212288
338054
201716
131998
125202
120710
117075
114099
111708
109603
107820
106320
105086
104074
103198
102592
102094
101640
101290
101006
100767
100571
100430
100305
100226
100158
100109
100074

result:

ok 31 numbers

Test #13:

score: 0
Accepted
time: 2073ms
memory: 14208kb

input:

30
BnAnnBB3fn33BffBBn3nfAABnBnfBfffBfBAf3Ann3nnfAnAAA
3Bn33ABnBnn3ffnfnnn3fB3Af33fBf3fnnBnBAAffBB33BnB3A3nBAnnABnf33AAAB3nnBA33nf33n3nBfnfnfABB3nBAA3ABAnAAB33A33ABfnAnA33f3fBBnBBfBnB3f3BBf3AAfBAAB3A3BnffBnf33nnffA33fAnffnBBB3nnBBfnBB33BffABn3n3BnAffBBA3nnnAfBfBnn3nn3fn3fn3B3AB3fBn3ABf3BAfAnAB3AAABB3...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
8
71
377
1675
6225
20231
54946
129079
258834
431560

result:

ok 31 numbers

Test #14:

score: 0
Accepted
time: 2033ms
memory: 16128kb

input:

30
BlXI1hCXN7XMD3h6ZFl8BFVBTgyh3R8oo74unTVVFKwjZCUjTzGqap3FSDU7KxycOFmh1au29Me8OEuSkS4Hd7DAzMVznUbBNuf3pqpud9t2B8F2M1OYziAPbmNynplDCtD3gbIkwSWV6H7Z2Uw4X12pPkFHM5Aisr4uVqggN2hdZGEhEVXNTbHSJ2teCsrO8pRUzKOnYDXIJ3hpkgELyRc7bn8UgQ2Rnhf4r2QA9kQqSSjqrCjGmzicFB9KjqOS2hq75WZRb1ZoI9cPyeOsYE6K9egR12hYCazoIQH8O...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 31 numbers

Test #15:

score: 0
Accepted
time: 2069ms
memory: 17884kb

input:

30
TmQyTaLuQVLUJdDWghdXyiWItuIYQ9GAw6TL0cyEvfBjrxXx2uBsynB5BCYxn6O6FPu9jzFj4wNA6YUaczxKT6yutPwAYo97NT7ygBXxLOnRn7aCwR6NN6m2Pj9J6bzZg3RUFU4MKomMuEYLo5jhB8P3RLp7SBmaCrzU8gumSb4W29YcIp4fHHzuGM4pfk0UFJoMHAsVSlvREO33TL24tgzFGJeZimMuZ1UKyVH6uk5kwCOcRu1N0FqRr33gTcFrNZO6CeUdDvlhhhJK5zJ9W4BUDtM9YUz2Xg2sWMs21...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 31 numbers

Test #16:

score: 0
Accepted
time: 2032ms
memory: 21080kb

input:

30
C0HKyslC6jquIZTK1eOiuyIv0wzje05Gvt8lvE2HauhsL8HYfTZ1dqKytoLKwWzryEsHBX3c5RGQ2KufkALf1DCHTafpG2drqjgLEwjwCpDyjRXRlskNCUkSOMONoB0yKiKCLcnNlWiZSlWlEcAiP62PvWjhAG2py5prF69coe4N7jANXk7hCvlIvYy5of0RT0eDhmXfSrnCk4C6lZ387hP7srzdqpjr2siBLXDmoehj6dyKwQmDZNuKUojOiUhqARlTIyiS7SvFUg5MZZ8HSk5s413XnEy489HKtqRLH...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 31 numbers

Test #17:

score: 0
Accepted
time: 2075ms
memory: 16820kb

input:

30
54n5bJBnw3pL2ufWznguJip98eTm3TZwBYnqD27KtOY99HpCbVWlN5WgUyYIvgLAY30XUeFbrG9MBqn39pigY0IoXz2E05YqDp7kCjj6RvO62ZmRxE8wXq0MZaHwiE2OdKPQuK4VVU4H4k4YPw1jOSsSoMfGd87a7ZDgd3bjXAXcz5GDVzapW8FmDzoqp5SCwZDO9ufWAJlSInx0VhYYTxuS3PyBsd9hLkXK2psGN59m1UcKOHWWMgGtBC5HMOkuo0Y1ipMvczy7KCBJZ08Mi6FT4TC1ghWdkWP4XLLtz...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 31 numbers

Test #18:

score: 0
Accepted
time: 2025ms
memory: 19508kb

input:

30
vt0ZfveKIwQqxHhk49gHI5EEK5y9Tsp9f0Cx1IKHwwvsrrTlE9xR2f2agCjhUAap8sHAR5zeQkQoAFQs3MqH1M2CYK0leBkVwIVP5Qt8vUNj8DEkR0TuuitiajMuKiAhDyd9CLkakRilkPL6nzDTwRaBF54S5rw3QXFDDTDDQceOH9YXA1JaFWS7zuggRx4E8dEAR4bcoRdHsizCzxDNawonNbjOKvxXYkIHcyBaPInsroxYkJTMn95k2CO6eT4MEioRWuz0Bhzab3UwHzzT0pH50zrUJeNHpUsN0RUqK...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 31 numbers

Test #19:

score: 0
Accepted
time: 1182ms
memory: 19228kb

input:

30
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

output:

50001
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002

result:

ok 31 numbers

Test #20:

score: 0
Accepted
time: 1231ms
memory: 14400kb

input:

30
GwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwGwG...

output:

2940
16575
47788
100929
178911
239421
260209
247737
229004
217495
206635
201055
195458
194778
194093
194093
194093
194093
194093
194093
194093
194093
194093
194093
194093
194093
194093
194093
194093
194093
194093

result:

ok 31 numbers

Test #21:

score: 0
Accepted
time: 1200ms
memory: 19196kb

input:

30
hxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxhxh...

output:

25001
100002
125002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002
100002

result:

ok 31 numbers

Test #22:

score: 0
Accepted
time: 1277ms
memory: 23372kb

input:

30
zZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZz...

output:

5001
20002
25002
20002
20002
20002
20002
20002
20002
20002
20002
20002
20002
20002
20002
20002
20002
20002
20002
20002
20002
20002
20002
20002
20002
20002
20002
20002
20002
20002
20002

result:

ok 31 numbers

Test #23:

score: 0
Accepted
time: 2249ms
memory: 19192kb

input:

30
wsMcrQ1i7cQbRu6ChwsMcrQ1i7cQbRu6ChwsMcrQ1i7cQbRu6ChwsMcrQ1i7cQbRu6ChwsMcrQ1i7cQbRu6ChwsMcrQ1i7cQbRu6ChwsMcrQ1i7cQbRu6ChwsMcrQ1i7cQbRu6ChwsMcrQ1i7cQbRu6ChwsMcrQ1i7cQbRu6ChwsMcrQ1i7cQbRu6ChwsMcrQ1i7cQbRu6ChwsMcrQ1i7cQbRu6ChwsMcrQ1i7cQbRu6ChwsMcrQ1i7cQbRu6ChwsMcrQ1i7cQbRu6ChwsMcrQ1i7cQbRu6ChwsMcrQ1i...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 31 numbers

Test #24:

score: 0
Accepted
time: 1793ms
memory: 19492kb

input:

30
v90JRqutBRmdP95O4v90JRqutBRmdP95O4v90JRqutBRmdP95O4v90JRqutBRmdP95O4v90JRqutBRmdP95O4v90JRqutBRmdP95O4v90JRqutBRmdP95O4v90JRqutBRmdP95O4v90JRqutBRmdP95O4v90JRqutBRmdP95O4v90JRqutBRmdP95O4v90JRqutBRmdP95O4v90JRqutBRmdP95O4v90JRqutBRmdP95O4v90JRqutBRmdP95O4v90JRqutBRmdP95O4v90JRqutBRmdP95O4v90JRqut...

output:

0
0
0
0
0
0
0
0
0
0
0
15
369
2181
6876
14558
24304
35430
47155
58923
70691
82458
94223
105990
117757
129522
141290
153091
165211
172759
165243

result:

ok 31 numbers

Test #25:

score: 0
Accepted
time: 2017ms
memory: 19492kb

input:

30
fhF5OawojWdaTvjuFbUBzlfX4ziBAMXEfGxnX1OevUW0P3ejLvl4k5gBn2KUFGR9eEvQS07HDHKvpWCi5T76rIgFH3ljytFBmM7SFLYxltxxTIjuBe92uQhFdS5X2LEobPAbntdm5qmuvdVeXY91fiMiO1j7EdGSrGrF2ek4PIpLYWorlwAhIcECg3pU84bi8cGFfytKqJbuas1bdOsM6oihwXjatbvq5DejPperOfhF5OawojWdaTvjuFbUBzlfX4ziBAMXEfGxnX1OevUW0P3ejLvl4k5gBn2KUFGR9...

output:

0
0
0
0
0
0
0
0
0
3
39
196
567
1153
1887
2706
3559
4417
5275
6134
6993
7851
8709
9567
10425
11283
12141
12999
13857
14716
15575

result:

ok 31 numbers

Test #26:

score: 0
Accepted
time: 2074ms
memory: 19264kb

input:

30
tsPnmYDfhxDbjUKfusmeKiDBffDMABWuxIiSnBiiUIVpc63CejvexMduUz9jCysafNa8R66l3Sg2Xe8p2mLluTxTbha1PhbxEGdMQ8QxnFzTkL4fZmUHKmieWga1kfeIC8cFCodOp260R7nqEwMVm95jdFHdxZEBtkmduZPOawvNxMpWwyJbOcX6c7hSYE2by9uV3LLFEcMdCGnMrLuorC7K4I9ZZW9l8sbJ18droy5Eql2B61G3nUzGuZLnxlaC6sFYg9sYruCvvM5sRNTej9uE81HfWw8j6KScvLrY8...

output:

0
0
0
0
0
0
0
0
1
8
31
74
132
203
285
371
457
543
629
715
801
887
973
1060
1147
1233
1319
1405
1491
1577
1663

result:

ok 31 numbers

Test #27:

score: 0
Accepted
time: 2080ms
memory: 19416kb

input:

30
4InvyDh20sJz28bC4tnk8up7fI7vlidMq7iDyWHZbyYts7cdEeKCOrIQTfSJj3K1RjejCTLALpPc5bXtnAVPwoomrpNpgUTUTmZ5P6F7sW9cUZuAfSVwxGVCuvycuenCg8z8BfzakvsTJVZswPxoATGR5aCi6jxSCCyxxBaD7OKrjqeOXybJn7OcGuAq41v1SVtTJWwTejfA31nj6G7JgasPsMXaioj3lyWOhamJ25gPzukGxOTYfAFIdAugkQSv8Hp1GLZRX9oUQwWXHLwL1mciFdcrcZg7xIU1tlxd3...

output:

0
0
0
0
0
0
0
0
0
1
4
8
12
18
27
37
47
57
67
77
87
97
107
117
127
137
147
157
167
177
187

result:

ok 31 numbers

Test #28:

score: 0
Accepted
time: 2062ms
memory: 19492kb

input:

30
bBovIcBRGxHntM3x06HeMJGa0yipLIC1oszgQEnV5wJRcO6yt5vIWa8H0ndAejTjga3b2Ku0xeV2XZIfmVJ2hlk3saZZhwTCQA3Vbllh9UKKzv5Ofk6yj2tsfoGJ6RYFRgYmUyLad4IQCNtKpXCZ3faixtClaTW9Rixp9yYuyyNn9rFDmshKD68Wd7z0Z6cxEBJHrfFbjI05uC5k8zIcKMTUNK5ELF7vDUcoKkBnZa82ygsXzi345gyZqZggOw2gSHV3jKKgQf5K4OEZS4YUnh1EiOcRV5CyJYVzkMcLs...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
2
7
13
19
25
31
37
43
49
55
61
67
73
79
85
91
97
103

result:

ok 31 numbers

Test #29:

score: 0
Accepted
time: 2062ms
memory: 19244kb

input:

30
cBuTSYusjkQuRKSKZAjHwhTZOwsk7ue5WFiaT5TE9LT7nymtLKho8XlaXzWxDbCB7PTQpmxKTkppaIT7duA5zOx4GCqwQ6LckJLlzXUwN09qzUAabZkWpKMCAXBBJ3Nozp5HcZlSV2Q7gHjz5OksFvdb4PduC5Nk7cRWrJ7R2MxV52oS2eyPxsFoFP2wU4WE4ETKIs8lygGR5qHhfE97PIIDIsEBIn1Sj66QX1jva9FMkfuO1fj2Wk0puCY6tzlc1P9bbtr5UZG3SGAVtEs6kFp1guRwEEPlFGZdOkYx2...

output:

0
0
0
0
0
0
0
0
0
1
3
5
7
9
11
13
16
20
24
28
32
36
40
44
48
52
56
60
64
68
72

result:

ok 31 numbers

Test #30:

score: 0
Accepted
time: 1373ms
memory: 19216kb

input:

30
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

output:

0
0
0
0
0
0
0
0
0
35285
27946
65059
86462
83569
52630
85019
51203
63998
112260
203934
247341
211464
120981
100002
100002
100002
100002
100002
100002
100002
100002

result:

ok 31 numbers

Test #31:

score: 0
Accepted
time: 1398ms
memory: 19188kb

input:

30
HKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKHKH...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
2783
19369
48486
69067
94730
130377
151683
153835
149942
149939
149936
149933
149930
149927
147197
144472
138997
133520

result:

ok 31 numbers

Test #32:

score: 0
Accepted
time: 1449ms
memory: 19508kb

input:

30
nXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXsnXs...

output:

0
0
0
0
0
0
0
0
0
0
0
2420
14660
44087
78325
98303
113677
129371
129951
126939
125227
126030
123924
126028
123921
126026
123918
126024
123915
126022
123912

result:

ok 31 numbers

Test #33:

score: 0
Accepted
time: 1524ms
memory: 19228kb

input:

30
K8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK8bdK...

output:

0
0
0
0
0
0
0
0
0
0
2106
10007
23837
43350
56473
63980
81186
103713
115013
121530
120866
116941
121169
118189
115201
117923
116830
115198
117920
116830
115193

result:

ok 31 numbers

Test #34:

score: 0
Accepted
time: 1588ms
memory: 19248kb

input:

30
aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aWJe6aW...

output:

0
0
0
0
0
0
0
0
0
1091
5317
14334
28961
49835
67902
81744
89579
96790
102587
112733
120993
125784
123682
119537
114598
114972
112952
112702
111928
113216
112116

result:

ok 31 numbers