QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#108002#4057. 子串统计xiaoyaowudi100 ✓599ms86480kbC++177.0kb2023-05-23 13:34:512023-05-23 13:34:56

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-23 13:34:56]
  • 评测
  • 测评结果:100
  • 用时:599ms
  • 内存:86480kb
  • [2023-05-23 13:34:51]
  • 提交

answer

#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
#include <numeric>
#include <tuple>
constexpr int N(1e5+10),p(998244353);
struct sam
{
	int link[N<<1],maxlen[N<<1],trans[N<<1][26],sz,lst,occ[N<<1];
	int ans[N<<1],nxt[N<<1],mnoc[N<<1],mxoc[N<<1];
	bool base[N<<1];
	sam(){sz=lst=1;}
	void extend(int id,int pos)
	{
		int cur(++sz);maxlen[cur]=maxlen[lst]+1;int p(lst);occ[cur]=1;
		mnoc[cur]=mxoc[cur]=pos;
		for(;p && !trans[p][id];p=link[p]) trans[p][id]=cur;
		if(!p) link[cur]=1;
		else
		{
			int q(trans[p][id]);
			if(maxlen[q]==maxlen[p]+1) link[cur]=q;
			else
			{
				int c(++sz);maxlen[c]=maxlen[p]+1;mnoc[c]=1e9;mxoc[c]=0;
				std::memcpy(trans[c],trans[q],sizeof(trans[c]));
				for(;p && trans[p][id]==q;p=link[p]) trans[p][id]=c;
				link[c]=link[q];link[q]=link[cur]=c;
			}
		}
		lst=cur;
	}
	void build()
	{
		static int idx[N<<1];
		std::iota(idx+1,idx+sz,2);
		std::sort(idx+1,idx+sz,[&](int a,int b)->bool{return maxlen[a]<maxlen[b];});
		std::iota(nxt+2,nxt+sz+1,2);
		for(int i(sz-1);i;--i)
		{
			int u(idx[i]);
			if(link[u]!=1)
			{
				occ[link[u]]+=occ[u];
				mnoc[link[u]]=std::min(mnoc[link[u]],mnoc[u]);
				mxoc[link[u]]=std::max(mxoc[link[u]],mxoc[u]);
			}
		}
		for(int i(1);i<sz;++i)
		{
			int u(idx[i]);
			int t(0);
			for(int j(0);j<26;++j) if(trans[u][j])
			{
				if(t) t=-1;
				else t=trans[u][j];
			}
			if(t>0 && occ[t]==occ[u])
			{
				nxt[t]=u;
			}
			else base[u]=true;
		}
	}
}T1,T2;
using ll=long long;
namespace polynomial
{
	constexpr int P(998244353),N(200010),PR(3),APR((P+1)/PR);
	int ws[2][N<<2],fac[N<<2],ifac[N<<2],fn,fb,lgg[N<<2],inv[N<<2],rev[N<<2];
	int fast_pow(int a,int b){int ans(1),off(a);while(b){if(b&1) ans=1ll*ans*off%P;off=1ll*off*off%P;b>>=1;}return ans;}
	void init_poly_weights(int len)
	{
		fn=1,fb=0;while(fn<(len<<1)) fn<<=1,++fb;
		inv[1]=1;for(int i(2);i<=fn;++i) inv[i]=1ll*(P-P/i)*inv[P%i]%P;
		ifac[0]=fac[0]=1;for(int i(1);i<=fn;++i) fac[i]=1ll*i*fac[i-1]%P,ifac[i]=1ll*ifac[i-1]*inv[i]%P;
		for(int i(0);i<fn;++i) rev[i]=(rev[i>>1]>>1)|((i&1)<<(fb-1));
		for(int i(2);i<=fn;++i) lgg[i]=lgg[(i+1)>>1]+1;
		for(int mid((fn>>1)),j0(fast_pow(PR,(P-1)/(mid<<1))),j1(fast_pow(APR,(P-1)/(mid<<1)));mid>=1;mid>>=1,j0=1ll*j0*j0%P,j1=1ll*j1*j1%P)
		for(int i(0),w0(1),w1(1);i<mid;++i,w0=1ll*w0*j0%P,w1=1ll*w1*j1%P) ws[0][i+mid]=w0,ws[1][i+mid]=w1;
	}
	using poly=std::vector<int>;
	int redu(int k){return k>=P?k-P:k;}
	poly operator+(const poly &a,const poly &b)
	{
		poly ret(b);if(ret.size()<a.size()) ret.resize(a.size());
		for(int i(0);i<a.size();++i) ret[i]=redu(ret[i]+a[i]);
		return ret;
	}
	unsigned long long tt[N<<2];
	void NTT(poly &p,int V)
	{
		int bts(lgg[p.size()]);if(p.size()!=(1<<bts)) p.resize((1<<bts));
		int* w(ws[(V==1)?0:1]),len(1<<bts);for(int i(0);i<len;++i) tt[i]=p[rev[i]>>(fb-bts)];
		unsigned long long t1,t2;
		for(int l(2);l<=len;l<<=1)
		{
			for(int j(0),mid=(l>>1);j<len;j+=l)
				for(int i(0);i<mid;++i) t1=tt[j+i],t2=tt[j+i+mid]*w[mid+i]%P,tt[j+i]=t1+t2,tt[j+i+mid]=P+t1-t2;
			if(l==2048) for(int j(0);j<len;++j) tt[j]%=P;
		}
		if(V==1) for(int i(0);i<len;++i) p[i]=tt[i]%P;
		else for(int i(0),j(inv[len]);i<len;++i) p[i]=tt[i]%P*j%P;
	}
	poly operator*(const poly &a,const poly &b)
	{
		static poly p1,p2;poly ret;
		p1=a,p2=b;int len(a.size()+b.size()-1),ff(1<<lgg[len]);
		p1.resize(ff),p2.resize(ff),ret.resize(ff);
		NTT(p1,1);NTT(p2,1);
		for(int i(0);i<ff;++i) ret[i]=1ll*p1[i]*p2[i]%P;
		NTT(ret,-1);ret.resize(len);return ret;
	}
	void print_poly(const poly &a){for(int v:a) std::cerr<<v<<" ";std::cerr<<std::endl;}
	const poly unit_poly={1};
}
using polynomial::poly;
using polynomial::operator*;
using polynomial::operator+;
using polynomial::init_poly_weights;
using polynomial::fac;
using polynomial::ifac;
using polynomial::inv;
using polynomial::print_poly;
int binom(int a,int b){return 1ll*fac[a]*ifac[b]%p*ifac[a-b]%p;}
namespace slv
{
	int x[N<<1],y[N<<1],val[N<<1],cnt,ans[N<<1],tmp[N<<1];
	void shl(poly &a,int k)
	{
		if(!k) return;
		int n(a.size());a.resize(n+k);
		std::rotate(a.begin(),a.begin()+n,a.end());
	}
	void sh1_x(poly &a,int k)
	{
		if(!k) return;
		poly f(k+1);
		for(int i(0);i<=k;++i)
		{
			if(i&1) f[i]=p-binom(k,i);
			else f[i]=binom(k,i);
		}
		a=a*f;
	}
	poly _slv(int l,int r)
	{
		if(l==r){return {val[l]};};
		int mid((l+r)>>1);
		auto pl=_slv(l,mid);
		auto pr=_slv(mid+1,r);
		shl(pr,x[mid+1]-x[l]);
		sh1_x(pl,y[r]-y[mid]);
		poly rp(pl+pr);
		return rp;
	}
	void slv()
	{
		poly G=_slv(1,cnt);
		shl(G,x[1]);poly F(x[cnt]+1);
		for(int i(0);i<=x[cnt];++i) F[i]=binom(i+y[cnt],y[cnt]);
		G=G*F;G.resize(x[cnt]+1);
		for(int i(0);i<=x[cnt];++i) ans[i]=G[i];
	}
}
int fp(int a,int b){int ans(1),off(a);while(b){if(b&1) ans=1ll*ans*off%p;off=1ll*off*off%p;b>>=1;}return ans;}
int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	static char s[N];std::cin>>(s+1);int n(std::strlen(s+1));init_poly_weights(n*2+1);
	for(int i(1);i<=n;++i) T1.extend(s[i]-'a',i),T2.extend(s[n-i+1]-'a',i);
	T1.build();T2.build();
	static std::tuple<int,int,int> s1[N],s2[N];
	int c1(0),c2(0);
	for(int i(2);i<=T1.sz;++i) if(T1.base[i]) s1[++c1]={T1.maxlen[i],T1.mnoc[i]-T1.maxlen[i]+1,i};
	for(int i(2);i<=T2.sz;++i) if(T2.base[i]) s2[++c2]={T2.maxlen[i],n-T2.mxoc[i]+1,i};
	std::sort(s1+1,s1+c1+1);
	std::sort(s2+1,s2+c2+1);
	T1.ans[1]=T2.ans[1]=((p+1)/2);
	for(int i(1);i<=c1;++i)
	{
		int x(std::get<2>(s1[i])),y(std::get<2>(s2[i]));
		static std::tuple<int,int,int> sx[N],sy[N],res[N<<1];int cx(0),cy(0);
		int xb(T1.maxlen[x]-T1.maxlen[T1.link[x]]),yb(T2.maxlen[y]-T2.maxlen[T2.link[y]]);
		for(int t(x);;t=T1.nxt[t])
		{
			++cx;sx[cx]={xb-(T1.maxlen[t]-T1.maxlen[T1.link[t]]),cx-1,T1.ans[T1.link[t]]};
			if(T1.nxt[t]==t) break;
		}
		for(int t(y);;t=T2.nxt[t])
		{
			++cy;sy[cy]={xb-cy,T2.maxlen[t]-T2.maxlen[T2.link[t]]-1,T2.ans[T2.link[t]]};
			if(T2.nxt[t]==t) break;
		}
		std::reverse(sy+1,sy+cy+1);
		std::merge(sx+1,sx+cx+1,sy+1,sy+cy+1,res+1);
		slv::cnt=0;
		for(int l(1),r;l<=cx+cy;l=r)
		{
			long long cur(0);auto [px,py,_]=res[l];
			for(r=l;r<=cx+cy && px==std::get<0>(res[r]) && py==std::get<1>(res[r]);cur+=std::get<2>(res[r]),++r);
			++slv::cnt;slv::x[slv::cnt]=px;slv::y[slv::cnt]=py;slv::tmp[slv::cnt]=cur;
			slv::val[slv::cnt]=cur*fp(T1.occ[x],py+1-px+p-1)%p;
		}
		slv::slv();
		for(int t(y),j(1);;t=T2.nxt[t],++j)
		{
			T2.ans[t]=1ll*slv::ans[xb-j]*fp(T1.occ[x],xb-j)%p;
			if(T2.nxt[t]==t) break;
		}
		for(int i(1);i<=slv::cnt;++i)
		{
			int tx(slv::x[i]),ty(slv::y[i]);
			slv::x[i]=yb-1-ty;slv::y[i]=xb-1-tx;
			slv::val[i]=1ll*slv::tmp[i]*fp(T1.occ[x],slv::y[i]-slv::x[i]+1+p-1)%p;
		}
		std::reverse(slv::x+1,slv::x+slv::cnt+1);
		std::reverse(slv::y+1,slv::y+slv::cnt+1);
		std::reverse(slv::val+1,slv::val+slv::cnt+1);
		slv::slv();
		for(int t(x),j(1);;t=T1.nxt[t],++j)
		{
			T1.ans[t]=1ll*slv::ans[yb-j]*fp(T1.occ[x],yb-j)%p;
			if(T1.nxt[t]==t) break;
		}
	}
	std::cout<<T1.ans[std::get<2>(s1[c1])]<<std::endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 5
Accepted
time: 9ms
memory: 6296kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

842068617

result:

ok 1 number(s): "842068617"

Test #2:

score: 5
Accepted
time: 21ms
memory: 8588kb

input:

zszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszz...

output:

670446466

result:

ok 1 number(s): "670446466"

Test #3:

score: 5
Accepted
time: 19ms
memory: 6716kb

input:

dedgdedfdedhdedfdedgdedfdedjdedfdedgdedfdedhdedfdedgdedfdedidedfdedgdedfdedhdedfdedgdedfdedkdedfdedgdedfdedhdedfdedgdedfdedidedfdedgdedfdedhdedfdedgdedfdedjdedfdedgdedfdedhdedfdedgdedfdedidedfdedgdedfdedhdedfdedgdedfdedldedfdedgdedfdedhdedfdedgdedfdedidedfdedgdedfdedhdedfdedgdedfdedjdedfdedgdedfdedh...

output:

736895071

result:

ok 1 number(s): "736895071"

Test #4:

score: 5
Accepted
time: 16ms
memory: 6640kb

input:

zszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszz...

output:

670446466

result:

ok 1 number(s): "670446466"

Test #5:

score: 5
Accepted
time: 28ms
memory: 7656kb

input:

kkhjihjjhhjhhikjjkijjjkkikjkjkjjkhjhjhhjijkhjkkkjijikhjhkkhkjhhijiijjjhkiiiikkjjhhkkjjijijkihkijihhikjkjkikikkkkkijjihjkkhiihkjkkkhkihkhhhjhjkihkhjjkikjkjhkhhjhhjiihiiiijiihjkhhihjhjjhjkiikiikhjihhkkjikijkjijjhkjijhihhihkhkjjkjjkkkhjhikkikikikkhijiiijjikiijihhkkjjjhikkjjkkkihjikihhikjijhkijkkiikhhik...

output:

500378111

result:

ok 1 number(s): "500378111"

Test #6:

score: 5
Accepted
time: 453ms
memory: 85752kb

input:

babbbbaabbabbaabaaaababaaaaababbbbbabbaaabbabbaaaaabbababbbaabaaaababbaaaaaababbbaaabbabbaaaabaaabaaababaababaabbbbababbaaaabaabbaabbaaaaabbbbababaabbabbaaaaababbabaabaabaaabaabbaaababbbabbbbbbaabbbabbababbbabaabbaaabaabababbabbbbbaaabbbaabbaaabaaababababaaababbbbbabbbbbaaabaaaaaaabaabbbabababbaabaa...

output:

276651135

result:

ok 1 number(s): "276651135"

Test #7:

score: 5
Accepted
time: 456ms
memory: 85664kb

input:

abababbbbbbababaaabbbabbabababaabaabbbaabbbabbbbbababaaaaabaabbbabbbabbaabbaabbbbbbabbaabbabbabaabbbbabbbbaabaabbbbaababbbaaabbbaabaabbbaabaaabbaaaaaabbbbbbaaaabbaaaabaabbabbbbbbaaabaababbabaabaabaabbbbbaaabbbaababbaababbbaabaabbbbbaabbbaaaabbbabaaaababbaabbababaaababbbbbbbbbbbbaabbabbabaaaaaaaaaaaa...

output:

400282964

result:

ok 1 number(s): "400282964"

Test #8:

score: 5
Accepted
time: 442ms
memory: 86480kb

input:

aaaabbbabbaabbbbbabbabbbbabbbabbaabbbaaabbaabababbababbaabaabbbbbaabbababbbbbababbaabbaaaabbbbbaababbbbbaaaaabbbbaababbbabaaaabbbbaabaaaaaaaabaabaabaabbaaaababaaaaabbbaabaaababaaaababaabbbbabaabaaaaaababbaaaabbaaabbbbaaababababbaababbaabbabbbabbbabbaabbbbabbabaababbbbbaaaaababbabaaaaaaabbbabaabaaaaa...

output:

729339954

result:

ok 1 number(s): "729339954"

Test #9:

score: 5
Accepted
time: 216ms
memory: 33844kb

input:

zszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszz...

output:

787319145

result:

ok 1 number(s): "787319145"

Test #10:

score: 5
Accepted
time: 283ms
memory: 47144kb

input:

jhkhhjhkkhjikkkjiiikjikjijijjiihkkkjiiihijiiikhhkiikiijikkjkhjhhkkihkkhjikhiikkhkkkhjhiijhkihkhjkjhkjkhhkjjjjhiiikkkihhikiijikhjjjijijjhkjjihhjikkkkkijijihhjjkihikjikijjijjikihjjhiiikhhihjjjhjhhijiiijikkihkjjkjihkjjkhkijjjiihhikkhjhjkikhikhjjkkkjhhiihiiihhkhjiikjjkjjkkijkijjkikhhkjhjhhhkjikkkhjiikhh...

output:

878766990

result:

ok 1 number(s): "878766990"

Test #11:

score: 5
Accepted
time: 259ms
memory: 38392kb

input:

xyyxxyxyxyyxxyyxxyxyyxxyxyxyyxxyyxxyxyxyyxxyyxxyxyyxxyxyxyyxxyyxxyxyyxxyxyxyyxxyyxxyxyyxxyxyxyyxxyyxxyxyxyyxxyyxxyxyyxxyxyxyyxxyyxxyxyyxxyxyxyyxxyyxxyxyxyyxxyyxxyxyyxxyxyxyyxxyyxxyxyxyyxxyyxxyxyyxxyxyxyyxxyyxxyxyyxxyxyxyyxxyyxxyxyyxxyxyxyyxxyyxxyxyxyyxxyyxxyxyyxxyxyxyyxxyyxxyxyxyyxxyyxxyxyyxxyxyxyyx...

output:

800644110

result:

ok 1 number(s): "800644110"

Test #12:

score: 5
Accepted
time: 295ms
memory: 42228kb

input:

xyyxxyxyyxxyyxxyxyyxxyxyyxxyxyyxxyyxxyxyyxxyxyyxxyyxxyxyyxxyyxxyxyyxxyxyyxxyyxxyxyyxxyxyyxxyxyyxxyyxxyxyyxxyyxxyxyyxxyxyyxxyxyyxxyyxxyxyyxxyxyyxxyyxxyxyyxxyyxxyxyyxxyxyyxxyyxxyxyyxxyxyyxxyxyyxxyyxxyxyyxxyxyyxxyyxxyxyyxxyyxxyxyyxxyxyyxxyyxxyxyyxxyxyyxxyxyyxxyyxxyxyyxxyyxxyxyyxxyxyyxxyxyyxxyyxxyxyyxxy...

output:

955468834

result:

ok 1 number(s): "955468834"

Test #13:

score: 5
Accepted
time: 312ms
memory: 45480kb

input:

xgltlxgflxglnaflbelxgbgfqltsxgltlxgflxglnaflxglqfjxglflxgflxglfgrglflulnaflbelxgbgfqltsxgltlxgflxgldglnaflxglqfjxglflxgflxglfgryglflulnaflbelxgbgfqltsxgltlxgfligfqltsxgltlxgflxglnaflxglqfjxglflxaxgltlxgflxglnaflbelxgbgfqltsxgltlxgflxglnaflxglqfjxglflxgflxglfgrglflulnaflbelxgbgfqltsxgltlxgflxgldglnaf...

output:

947232801

result:

ok 1 number(s): "947232801"

Test #14:

score: 5
Accepted
time: 588ms
memory: 75408kb

input:

zszsszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszz...

output:

560729572

result:

ok 1 number(s): "560729572"

Test #15:

score: 5
Accepted
time: 583ms
memory: 81400kb

input:

ijjijiijjiijijjijiiiijjiijjijiijjiijijjiijjijiijijjijiijjiijijjijiijijjiijjijiijijjijiijjiijijjiijjijiijjiijijjijiijijjiijjijiijjiijijjiijjijiijijjijiijjiijijjiijjijiijjiijijjijiijijjiijjijiijijjijiijjiijijjijiijijjiijjijiijjiijijjiijjijiijijjijiijjiijijjijiijijjiijjijiijijjijiijjiijijjiijjijiijjiij...

output:

881489605

result:

ok 1 number(s): "881489605"

Test #16:

score: 5
Accepted
time: 528ms
memory: 77800kb

input:

khkjkjkjjkkihikjijiikjkhhkjhikkjihkijihkikiihjikhhiikhhjjkjhhijjhihhkhjkkhijjiikjjikkijkkijhhhijijiijkjijhjihhhikikhjihhjjikkijkhkjjjihjjikjihkhhikijjihjhkjhjjjhjhhhiiijikhjkjikkijhiijhkkikhjhihhikhjhjkihhkhhihhjjhhiiihjiijhjkhhkjkjikjkikikjjjhiikijijiijkijjihjjhhikiiihkihhjkjjhjjikhjkjjkhjkijhkhjjk...

output:

121066948

result:

ok 1 number(s): "121066948"

Test #17:

score: 5
Accepted
time: 351ms
memory: 68104kb

input:

ghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghghgh...

output:

394568528

result:

ok 1 number(s): "394568528"

Test #18:

score: 5
Accepted
time: 510ms
memory: 71420kb

input:

xyxxyxyxxyxxyxxyxyxxyxxyxyxxyxyxxyxxyxyxxyxxyxxyxyxxyxyxxyxxyxxyxyxxyxyxxyxxyxxyxyxxyxxyxyxxyxyxxyxxyxyxxyxxyxxyxyxxyxyxxyxxyxxyxyxxyxxyxyxxyxyxxyxxyxyxxyxxyxxyxyxxyxxyxyxxyxyxxyxxyxyxxyxxyxxyxyxxyxyxxyxxyxxyxyxxyxyxxyxxyxxyxyxxyxxyxyxxyxyxxyxxyxyxxyxxyxxyxyxxyxxyxyxxyxyxxyxxyxyxxyxxyxxyxyxxyxyxxyxx...

output:

380248771

result:

ok 1 number(s): "380248771"

Test #19:

score: 5
Accepted
time: 599ms
memory: 81092kb

input:

tgndlgndjrgxtgndjtgndlgxtgngunmxjgxtkdjtgndlgndjtgndlgxtgjgndlgxjgxtgndlgxtgngunmxjgxtgndjtgndlgxtgngunmxjgxtkdjtgndlgndjtgndlgxtgngundndjtgndlgxtgngunmxjgxtkdjtgndljtkdjtgndlgndjtgndlgxtgjgndxjtgndlgxtgngunyndjtgndlgxtgngunmxjgxtkdjtgndlgndjtgndlgxtgjgndlgxdlgxjgxtgndlgxtgngunmxjgxtgndjtgndlgxtgngu...

output:

379249648

result:

ok 1 number(s): "379249648"

Test #20:

score: 5
Accepted
time: 572ms
memory: 80624kb

input:

jihihiikhkkkjikjhijkijkjiiihhjhikjhkijiiihjjhjjjikkkikihjkhhkjjhijkiikkkjiijikjkkhiihikijjkhikiikkjjhkikjjjjhkhjikihiihkijkhjhkkjjhjkjkkkhjjkhkihihhhkkkjhkkjhijjhkhijhkijjjikjjkjkhikjjhkkjihkihijhjhkkkhkjjijhjjkhjiihhkkjhhjhjikikijjjkkhiijhjjihkkihikikijhkhikiijkkiiihhjkhihhkkhihiijhkhiiikiijihkijhh...

output:

113827949

result:

ok 1 number(s): "113827949"