QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#440195#5014. 复读程度C1942huangjiaxu22 3412ms87132kbC++146.5kb2024-06-13 11:53:182024-06-13 11:53:18

Judging History

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

  • [2024-06-13 11:53:18]
  • 评测
  • 测评结果:22
  • 用时:3412ms
  • 内存:87132kb
  • [2024-06-13 11:53:18]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5,M=4e5+5;
typedef unsigned long long ull;
int n,m,tot;
ull wl[N],wr[N],Ans[N],ans[M],nans;
char s[N];
struct node{
	int ch[26],len,fa;
};
struct SAM{
	node tr[N];
	int str[N],son[N][26],occ[N],pos[N],bel[N],ip[N],sz[N];
	ull sum[N];
	int cnt=1,ls=1;
	int fa[N][19],in[N],out[N];
	vector<int>e[N];
	void ins(int c){
		int p=ls,np=ls=++cnt;
		tr[np].len=tr[p].len+1;
		str[tr[np].len]=c,ip[tr[np].len]=np;
		for(;p&&!tr[p].ch[c];p=tr[p].fa)tr[p].ch[c]=np;
		if(!p)tr[np].fa=1;
		else{
			int q=tr[p].ch[c];
			if(tr[q].len==tr[p].len+1)tr[np].fa=q;
			else{
				int nq=++cnt;tr[nq]=tr[q];
				tr[nq].len=tr[p].len+1,tr[np].fa=tr[q].fa=nq;
				for(;p&&tr[p].ch[c]==q;p=tr[p].fa)tr[p].ch[c]=nq;
			}
		}
	}
	void dfs(int x){
		in[x]=++in[0];
		for(int i=1;i<19;++i)fa[x][i]=fa[fa[x][i-1]][i-1];
		for(auto v:e[x]){
			fa[v][0]=x;
			sz[v]=tr[v].len-tr[x].len;
			dfs(v);
			sum[x]+=sum[v];
			occ[x]+=occ[v];
			pos[x]=min(pos[x],pos[v]);
		}
		out[x]=in[0];
	}
	void build(ull *w){
		for(int i=1;i<=cnt;++i)e[tr[i].fa].emplace_back(i),pos[i]=1e9;
		int u=1;
		for(int i=1;i<=n;++i){
			u=tr[u].ch[str[i]];
			++occ[u];
			pos[u]=i,sum[u]=w[i];
		}
		dfs(1);
		for(int i=2;i<=cnt;++i)son[tr[i].fa][str[pos[i]-tr[tr[i].fa].len]]=i;
	}
	void feed(vector<int>* res){
		for(int u=cnt;u;--u){
			if(!bel[u])for(int i=0;i<26;++i)if(tr[u].ch[i])bel[u]=bel[tr[u].ch[i]];
			res[bel[u]].push_back(u);
		}
	}
	int find(int l,int r){
		int x=ip[r];
		for(int i=18;~i;--i)if(fa[x][i]&&tr[fa[x][i]].len>=r-l+1)x=fa[x][i];
		return x;
	}
	void print(){
		printf("cnt %d\n",cnt);
		for(int i=2;i<=cnt;++i){
			printf("id %d\n",i);
			printf("ln %d fa %d\n",tr[i].len,tr[i].fa);
			printf("occ %d pos %d sum %llu\n",occ[i],pos[i],sum[i]);
		}
	}
}s1,s2;
struct qry1{
	int l,r,id,x;
	ull va;
};
struct Bit{
	ull tr[N];
	void upd(int x,ull v){
		for(;x<N;x+=x&-x)tr[x]+=v;
	}
	ull sum(int x){
		ull res=0;
		for(;x;x-=x&-x)res+=tr[x];
		return res;
	}
	ull sum(int l,int r){
		return sum(r)-sum(l-1);
	}
}bit;
struct qry2{
	int x,y,id;
}q[M];
bool cmp(qry2 a,qry2 b){
	int pa=a.x>>9,pb=b.x>>9;
	if(pa!=pb)return pa<pb;
	return (pa&1)?a.y>b.y:a.y<b.y;
}
vector<int>rid[N],cid[N];
vector<qry1>qc[N],qr[N],tq[N];
int rp[N],cp[N],occ[N],rvx[N],rvy[N],bx[N],by[N];
int qid[M],cq;
void dfs(int x,int y){
	bool fg=s1.tr[x].len==s2.tr[y].len;
	if(fg)s1.bel[x]=s2.bel[y]=++tot,occ[tot]=s1.occ[x];
	for(int i=0;i<26;++i)if(s1.tr[s1.tr[x].ch[i]].len==s1.tr[x].len+1)
		dfs(s1.tr[x].ch[i],fg?s2.son[y][i]:y);
}
ull calc(int X,int Y){
	ull res=0;
	for(int i=2;i<=tot;++i){
		for(int j=0;j<rid[i].size();++j){
			int v=rid[i][j];
			if(s1.in[v]>X)continue;
			for(int k=0;k<s1.sz[v];++k){
				int u=cid[i][k];
				if(s2.in[u]>Y)continue;
				res+=1ll*s1.sum[v]*s2.sum[u]*occ[i];
			}
		}
	}
	return res;
}
void qry(int l1,int r1,int l2,int r2,int id){
	int p1=s1.find(l1,r1),p2=s2.find(n-r2+1,n-l2+1);
	int ln1=r1-l1+1,ln2=r2-l2+1;
	int y1=rp[p1],x1=s1.tr[p1].len-ln1,x2=cp[p2],y2=s2.tr[p2].len-ln2;
	//printf("?%d %d %d %d %d %d %d %d\n",s1.bel[p1],s2.bel[p2],p1,p2,x1,y1,x2,y2);
	if(s1.bel[p1]==s2.bel[p2]){
		if(x1!=x2||y1!=y2)
			if(x2>x1&&x2<s1.sz[p1]||y1>y2&&y1<s2.sz[p2])
				Ans[id]-=s1.sum[p1]*s2.sum[p2]*s1.occ[p1];
	}else{
		int o=s1.bel[p1];
		if(x1+1<s1.sz[p1]){
			qc[o].push_back({s2.in[p2],s2.out[p2],id,-x1,s1.sum[p1]*occ[o]});
			qc[o].push_back({s2.in[p2],s2.out[p2],id,s1.sz[p1]-1,s1.sum[p1]*occ[o]});
		}
		o=s2.bel[p2];
		if(y2+1<s2.sz[p2]){
			qr[o].push_back({s1.in[p1],s1.out[p1],id,-y2,s2.sum[p2]*occ[o]});
			qr[o].push_back({s1.in[p1],s1.out[p1],id,s2.sz[p2]-1,s2.sum[p2]*occ[o]});
		}
	}
	q[++cq]={s1.out[p1],s2.out[p2],0},qid[cq]=id;
	q[++cq]={s1.in[p1]-1,s2.out[p2],0},qid[cq]=-id;
	q[++cq]={s1.out[p1],s2.in[p2]-1,0},qid[cq]=-id;
	q[++cq]={s1.in[p1]-1,s2.in[p2]-1,0},qid[cq]=id;
}
void solve(int o){
	for(int i=0;i<cid[o].size();++i)tq[i].clear();
	for(auto v:qc[o]){
		if(v.x<0)tq[-v.x].push_back({v.l,v.r,v.id,-1,v.va});
		else tq[v.x].push_back({v.l,v.r,v.id,1,v.va});
	}
	for(int i=1;i<cid[o].size();++i){
		int u=cid[o][i];
		bit.upd(s2.in[u],s2.sum[u]);
		for(auto v:tq[i])Ans[v.id]-=bit.sum(v.l,v.r)*v.va*v.x;
	}
	for(int i=1;i<cid[o].size();++i){
		int u=cid[o][i];
		bit.upd(s2.in[u],-s2.sum[u]);
	}
	for(int i=0;i<rid[o].size();++i)tq[i].clear();
	for(auto v:qr[o]){
		if(v.x<0)tq[-v.x].push_back({v.l,v.r,v.id,-1,v.va});
		else tq[v.x].push_back({v.l,v.r,v.id,1,v.va});
	}
	for(int i=1;i<rid[o].size();++i){
		int u=rid[o][i];
		bit.upd(s1.in[u],s1.sum[u]);
		for(auto v:tq[i])Ans[v.id]-=bit.sum(v.l,v.r)*v.va*v.x;
	}
	for(int i=1;i<rid[o].size();++i){
		int u=rid[o][i];
		bit.upd(s1.in[u],-s1.sum[u]);
	}
}
void Print(){
	printf("tot %d\n",tot);
	for(int i=1;i<=tot;++i){
		printf("bel %d occ %d\n",i,occ[i]);
		printf("rid\n");
		for(auto v:rid[i])printf("%d %d\n",v,s1.sz[v]);
		printf("cid\n");
		for(auto v:cid[i])printf("%d %d\n",v,s2.sz[v]);putchar(10);
	}
}
void chgx(int x,int Y,int ty){
	int v=rvx[x],o=bx[x];
	for(int i=0;i<s1.sz[v];++i){
		int u=cid[o][i];
		if(s2.in[u]<=Y)nans+=s1.sum[v]*s2.sum[u]*occ[o]*ty;
	}
}
void chgy(int X,int y,int ty){
	int v=rvy[y],o=by[y];
	for(int i=0;i<s2.sz[v];++i){
		int u=rid[o][i];
		if(s1.in[u]<=X)nans+=s2.sum[v]*s1.sum[u]*occ[o]*ty;
	}
}
void Solve(){
	for(int i=1;i<=cq;++i)q[i].id=i;
	sort(q+1,q+cq+1,cmp);
	for(int i=1,X=0,Y=0;i<=cq;++i){
		while(X<q[i].x)chgx(++X,Y,1);
		while(Y<q[i].y)chgy(X,++Y,1);
		while(X>q[i].x)chgx(X--,Y,-1);
		while(Y>q[i].y)chgy(X,Y--,-1);
		ans[q[i].id]=nans;
	}
}
int main(){
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	for(int i=1;i<=n;++i)scanf("%llu",&wl[i]);
	for(int i=1;i<=n;++i)scanf("%llu",&wr[i]);
	for(int i=1;i<=n;++i)s[i]-='a';
	for(int i=1;i<=n;++i)s1.ins(s[i]);
	for(int i=n;i;--i)s2.ins(s[i]);
	s1.build(wr);
	reverse(wl+1,wl+n+1);
	s2.build(wl);
	dfs(1,1);
	s1.feed(rid),s2.feed(cid);
	//s1.print(),s2.print();
	//Print();
	for(int i=1;i<=tot;++i){
		for(int j=0;j<rid[i].size();++j){
			int v=rid[i][j];
			rp[v]=j,rvx[s1.in[v]]=v;
			bx[s1.in[v]]=i;
		}
		for(int j=0;j<cid[i].size();++j){
			int v=cid[i][j];
			cp[v]=j,rvy[s2.in[v]]=v;
			by[s2.in[v]]=i;
		}
	}
	for(int i=1,l1,r1,l2,r2;i<=m;++i){
		scanf("%d%d%d%d",&l2,&r2,&l1,&r1);
		qry(l1,r1,l2,r2,i);
	}
	for(int i=2;i<=tot;++i)solve(i);
	Solve();
	for(int i=1;i<=cq;++i){
		if(qid[i]<0)Ans[-qid[i]]-=ans[i];
		else Ans[qid[i]]+=ans[i];
	}
	for(int i=1;i<=m;++i)printf("%llu\n",Ans[i]);
	return 0;
}

详细

Subtask #1:

score: 7
Accepted

Test #1:

score: 7
Accepted
time: 41ms
memory: 73692kb

input:

500 500
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

15720454042420499810
4058077030882532408
14651762045124606089
4030024243931986061
18033423360813892607
9470601111824364484
3883374861354698625
16650831689368240202
8339028189650687576
2683289915379600554
13133811958066776394
14181220923901262251
18173739360450512256
13142314545999179754
148925491596...

result:

ok 500 lines

Test #2:

score: 7
Accepted
time: 34ms
memory: 75824kb

input:

500 500
zszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszz...

output:

4843650749197240262
7777110205341291111
533576317536031175
16712994243500559204
9988085877723856684
9644193924482321332
3247342125341043527
18152622312040037224
13045121434804725850
10593529771756855740
13316626648976199221
6181092693273210423
9148547538129213975
9376364571107435561
2140403332478526...

result:

ok 500 lines

Test #3:

score: 7
Accepted
time: 47ms
memory: 73724kb

input:

500 500
aaaaabbaabbabbbaabaabbabbabbbaaabaaaabbbbbbaaabaabbbbbbaabbaaaaababbaaaaabbbbababbabaabbbbbbbbaaaaaaabaabbabbbbaabbaabaaabbbabbaabbbabaabaaaaababbaabbabbbabbababbbaabbabaaabbbbaaabbbabbabaabbabbaaabbaabbabbbbaaaaaababaaaabaababbaabbabbabbbabbaabbbaabbaaababaaabbababbbabaababaabbbbbabbababaab...

output:

841375054012212333
13406426787139944226
6541986259052503362
10583258635957015782
11582649090627508617
4747829250201069768
11571422754704651998
14603866222879735665
8438246043626601023
16155298152184479844
9052925087624568857
18388444310571976215
13304308468056840286
18125780089857220122
363421144082...

result:

ok 500 lines

Test #4:

score: 7
Accepted
time: 29ms
memory: 71840kb

input:

500 500
sulasusulasusulasulasulsulasusulasususulasulasulsulasulasulsulasulasulsulasususulasulasulsulasulasulsulasulasulsulasusulasulasulsulasulasulsulasulasulsulasusulasulasulsulasulasulsulasulasulsulasulasulsulasususulasulasulsulasulasulsulasulasulsulasusulasulasulsulasulasulsulasusulasusulasusulas...

output:

2320755102639148175
17108462705447992416
6030359132551843296
889683039894413148
10901851555398837076
1991544941914879425
9087724446342520941
5134546535199286414
12947484109492427089
5962550827492657739
4877066450610765849
6699323319072695780
11167645157062070624
13985172887966350800
8075429763917070...

result:

ok 500 lines

Test #5:

score: 7
Accepted
time: 24ms
memory: 73756kb

input:

500 500
bbbbbbqouvtudkzorrxinacvncytgmtbbbbbbfyfzxjdqlcaadccvsbbbbbbqouvtudkzorrxinacvncytgmtbbbbbbbbbbbbqouvtudkzorrxinacvncytgmtbbbbbbfyfzxjdqlcaadccvsbbbbbbqouvtudkzorrxinacvncytgmtbbbbbbbbbbbbqouvtudkzorrxinacvncytgmtbbbbbbfyfzxjdqlcaadccvsbbbbbbqouvtudkzorrxinacvncytgmtbbbbbbbbbbbbqouvtudkzorrx...

output:

18295637548117042088
6105463594888898313
15681140870484623884
17957090271580958329
11763132903578154240
17769627666201366836
16493946443969420940
12712093409624537595
2436698665645215125
8863273927617841787
5065586857868462806
8771649105206144878
6715985691821336097
8851433094837196039
7055234226266...

result:

ok 500 lines

Test #6:

score: 7
Accepted
time: 38ms
memory: 75892kb

input:

500 500
yyyayyayyyayyayyyayyayyyayyyayyyayyayyyyayyayyyayyyayyayyyayyyayyayyayyyyayyyayyyayyayyayyyayyayyayyyayyayyayyyayyyyyayyayyyyayyayyyayyayyyayyyayyyayyayyyayyayyyyayyyayyayyayyyayyayyyayyyyayyyyayyayyyayyayyayyyayyayyayyyyayyayyyayyayyayyyayyyyayyayyayyyayyayyayyyayyayyayyyyayyyayyyayyyyayyay...

output:

6159560444195180556
5294852391541430076
6195718271241091926
7959984071139675340
1598729415848168155
4879964117998052348
2279721248493220290
2026655128556749470
9803272548967597498
1028236064772678471
5410852487707111065
3600180224455323043
60239358603452318
2179897463397058094
16626503365867372202
3...

result:

ok 500 lines

Test #7:

score: 7
Accepted
time: 30ms
memory: 73828kb

input:

500 500
fffffffffffxfqifffnmogfffxfqiffffffffxfqifffnmogfffxfqiffffffxfqifffnmogfffxfqifffffffffffxfqifffnmogfffxfqiffffffffxfqifffnmogfffxfqifffffffffffffxfqifffnmogfffxfqiffffffffxfqifffnmogfffxfqifffffffffxfqifffnmogfffxfqiffffffffxfqifffnmogfffxfqiffffffffxfqifffnmogfffxfqiffffffffxfqifffnmogfff...

output:

6263422992304461664
10533199195660359295
11930245273187149005
380050211417129795
8399013088311259527
7005867409130681392
6872331929648615383
11661502418569897193
18027795221888639599
8932010711134684820
6331436398298306214
14599171184201697655
16632037523890780117
10373998601812781913
16089838760431...

result:

ok 500 lines

Subtask #2:

score: 15
Accepted

Dependency #1:

100%
Accepted

Test #8:

score: 15
Accepted
time: 2190ms
memory: 82904kb

input:

5000 5000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

12046186417900804485
3907200386448639860
16785470842023310270
13867397394972404837
17085398553187209926
11495532885795119226
12151570815045120790
4174337022608077877
6326694597133262496
5169007805286709535
14463367619086789683
627371028328452442
16378439470252322552
8286285259552634235
4646456254657...

result:

ok 5000 lines

Test #9:

score: 15
Accepted
time: 2730ms
memory: 82144kb

input:

5000 5000
zszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzs...

output:

735272585091871492
2425556370857741242
8489901764977622765
9888756352722135114
3110111362923242403
9113727892967247055
13146817111311386931
5955980702194075793
11763307103994511020
11636340521260903139
13880517640770645879
18280247001976771986
9041182678245966519
902847942097731925
17037540142883387...

result:

ok 5000 lines

Test #10:

score: 15
Accepted
time: 2545ms
memory: 82232kb

input:

5000 5000
bababbaabbbbbabbabaababbbaabababbbbaaabbaabbbbaaabaaaaabbababaababbbabbabbaaabbaaaaaababbababbbbbabbbbbaaabbabababaaababbababaabaaaaaabaaabbabaaaabaabaaaaaabbaaaaaaabbbbbabbabababbbabababaabaabbbbbabaabbbaaabbaaababbabaabaabbababaaaaaaabaaaabaabbbabbaaaababbabbaaabbbbabbabbaabbabbbbabaabbb...

output:

14997976760389310587
15623438489514479805
3150343034406864174
3816221098639928267
9378704101760633024
7513129444188437491
13447233088170491140
9761793475353455477
14533020333667464089
3755460369265761557
1017346093533703703
13617526768501762999
3768834851789866303
6158131626925412903
362975187944345...

result:

ok 5000 lines

Test #11:

score: 15
Accepted
time: 2193ms
memory: 80312kb

input:

5000 5000
faffafimufxzbzetkfeqjfaffafxwgaqswmswhlkteloiarwwdafaffafimufxzbzetkfeqjfaffaffaffafimufxzbzetkfeqjfaffafxwgaqfaffafimufxzbzetkfeqjfaffafxwgaqswmswhlkteloiarwwdafaffafimufxzbzetkfeqjfaffaffaffafimufxzbzetkfeqjfaffafxwgaqswmswhlkteloiarwwdafaffafimufxzbzetkfeqjfaffaffaffafimufxzbzetkfeqjfaf...

output:

1845388242333177970
9831947454379400267
1031368185674017505
7263197708536716267
14239370791222150808
146482920919415220
17250529541921412624
16073012951843647214
14426094333257632462
9475986787147068259
17618123199330645299
7007181348027660953
7868744985222980634
24008326611725469
109704767314001231...

result:

ok 5000 lines

Test #12:

score: 15
Accepted
time: 3412ms
memory: 81524kb

input:

5000 5000
rreurrrrkodwxsvtckttkrreurrrrtvjqcbspphhcmqjjadnkvdhavzhasjorreurrrrkodwxsvtckttkrreurrrrdhzorreurrrrkodwxsvtckttkrreurrrrtvjqcbspphhcmqjjadnkvdhavzhasjorreurrrrkodwxsvtckttkrreurrrrxgpkocctymfhcjougjsvimxuwczjxyhasapncenwpvkvtrmcdhkfjmndumgccngxginwyjhwexjeujrnvfaznvonweytryeeoocesoxavgaw...

output:

11585208823777493396
6508373161762025375
8952030838195753202
1744593196955201879
7361869313836500243
4211703722346758091
11507326811546869387
12152026172660216436
6502452509264613488
16456537462830488502
7769483154726766332
5049920983662723085
6208254085958990276
1561961237223372279
2581189727041718...

result:

ok 5000 lines

Test #13:

score: 15
Accepted
time: 2787ms
memory: 80216kb

input:

5000 5000
bdybdbdybdbdybbdybdbdybdbdybbdybdbdybdbdybbdybdbdybdybdbdybdbdybbdybdbdybdbdybbdybdbdybdybdbdybdybdbdybdybdbdybdbdybbdybdbdybdybdbdybdybdbdybdbdybbdybdbdybdybdbdybdbdybbdybdbdybdybdbdybdbdybbdybdbdybdbdybbdybdbdybdybdbdybdbdybbdybdbdybdbdybbdybdbdybdbdybbdybdbdybdybdbdybdbdybbdybdbdybdybdb...

output:

15484750028865001809
11154229346905269019
17415778058314228645
12967502341758445430
14197547387946783600
16593119823307221414
3430123628603013461
15944735630911629097
3372966924712269006
16370170534370111687
7776152546511005126
10081736260495879969
3361043444817366723
14159037165445633566
4790222378...

result:

ok 5000 lines

Test #14:

score: 15
Accepted
time: 2175ms
memory: 80180kb

input:

5000 5000
gskozovzgkcfxgrjipkmaurpgskozovzgkcfxuetjsdskistgkrkxbvpwljcjmnamkcdqmeteslgskozovzgkcfxgrjipkmaurpgskozovzgkcfxgskozovzgkcfxgrjipkmaurpgskozovzgkcfxuetjsdskistgkrkgskozovzgkcfxgrjipkmaurpgskozovzgkcfxuetjsdskistgkrkxbvpwljcjmnamkcdqmeteslgskozovzgkcfxgrjipkmaurpgskozovzgkcfxgskozovzgkcfxg...

output:

5804930040756324744
15650208817097681461
11355021187259627510
6741010156229702848
11225541410427015147
1272653894362217625
8025793205090026227
17985669688971641284
17805739950886098400
15447039299473890938
13822612697353510946
16409494890413019301
10397340813113479673
11748441386197961568
1796390231...

result:

ok 5000 lines

Subtask #3:

score: 0
Time Limit Exceeded

Dependency #2:

100%
Accepted

Test #15:

score: 12
Accepted
time: 292ms
memory: 87132kb

input:

5000 100000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

5845120425902525283
8990351971173725430
14941690660751686216
784971306663465014
14729108738538674226
9552307739797797498
3551599368844499432
3212787150504387790
8594382131237834529
16887368685328314652
5586192237324217034
12381470524748547090
1961055982585971300
13257376816999825159
3385756250295802...

result:

ok 100000 lines

Test #16:

score: 0
Time Limit Exceeded

input:

5000 100000
zszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszszzszzszszzszzszszzszszzszzszszzszsz...

output:


result:


Subtask #4:

score: 0
Time Limit Exceeded

Test #22:

score: 0
Time Limit Exceeded

input:

100000 100000
zbbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaabab...

output:


result:


Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Time Limit Exceeded

Dependency #2:

100%
Accepted

Test #32:

score: 0
Time Limit Exceeded

input:

50000 50000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:


result:


Subtask #7:

score: 0
Skipped

Dependency #3:

0%