QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#454321#1789. 密码箱SimonLJK100 ✓1022ms46064kbC++143.6kb2024-06-24 19:26:302024-06-24 19:26:31

Judging History

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

  • [2024-06-24 19:26:31]
  • 评测
  • 测评结果:100
  • 用时:1022ms
  • 内存:46064kb
  • [2024-06-24 19:26:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
const int N=2e5+99;
int n,q;
string str;
struct Matrix{
	ll a[2][2];
	Matrix(){ a[0][0]=a[1][1]=1; a[0][1]=a[1][0]=0; }
	void init(){ memset(a,0,sizeof(a));	}
}WE[2];
Matrix operator *(Matrix A,Matrix B){
	Matrix C; C.init();
	for(int i=0;i<=1;i++)
		for(int j=0;j<=1;j++)
			for(int k=0;k<=1;k++)
				C.a[i][k]=(C.a[i][k]+A.a[i][j]*B.a[j][k])%mod;
	return C; 
}
struct tree{
	int val,sz,ln,rn;
	int tagf,tagr;
	Matrix v[2];
	Matrix m[2][2];
	// a_i_j 是否flip状态为i,是否reverse状态为j
	tree(){ ln=rn=0; tagf=tagr=0; }
}tr[N];
int cntnode,rt;
void pushdown(int node){
	int ln=tr[node].ln,rn=tr[node].rn;
	if(tr[node].tagf){
		swap(tr[ln].v[0],tr[ln].v[1]);
		swap(tr[ln].m[0],tr[ln].m[1]);
		swap(tr[rn].v[0],tr[rn].v[1]);
		swap(tr[rn].m[0],tr[rn].m[1]);
		tr[ln].tagf^=1; tr[rn].tagf^=1;
		tr[node].tagf=0;
	}
	if(tr[node].tagr){
		swap(tr[ln].m[0][0],tr[ln].m[0][1]);
		swap(tr[ln].m[1][0],tr[ln].m[1][1]);
		swap(tr[rn].m[0][0],tr[rn].m[0][1]);
		swap(tr[rn].m[1][0],tr[rn].m[1][1]);
		swap(tr[ln].ln,tr[ln].rn);
		swap(tr[rn].ln,tr[rn].rn);
		tr[ln].tagr^=1; tr[rn].tagr^=1;
		tr[node].tagr=0;
	}
	return;
}
void pushup(int node){
	int ln=tr[node].ln,rn=tr[node].rn;
	tr[node].sz=tr[ln].sz+1+tr[rn].sz; 
	for(int i=0;i<=1;i++)
		for(int j=0;j<=1;j++)
			if(j==0)
				tr[node].m[i][j]=tr[ln].m[i][j]*tr[node].v[i]*tr[rn].m[i][j];
			else
				tr[node].m[i][j]=tr[rn].m[i][j]*tr[node].v[i]*tr[ln].m[i][j];
	return;
}
int merge(int x,int y){
	if(!x||!y) return x+y;
	pushdown(x); pushdown(y);
	if(tr[x].val<tr[y].val){
		tr[x].rn=merge(tr[x].rn,y);
		pushup(x); return x;
	}
	else{
		tr[y].ln=merge(x,tr[y].ln);
		pushup(y); return y;
	}
}
pair<int,int> split(int x,int num){
	if(!num) return make_pair(0,x);
	pushdown(x);
	int ln=tr[x].ln,rn=tr[x].rn;
	pair<int,int> now;
	if(tr[ln].sz>=num){
		now=split(ln,num);
		tr[x].ln=now.second;
		pushup(x);
		return make_pair(now.first,x);
	}
	else{
		now=split(rn,num-tr[ln].sz-1);
		tr[x].rn=now.first;
		pushup(x);
		return make_pair(x,now.second);
	}
}
void add(int tp){
	++cntnode;
	tr[cntnode].val=rand(); tr[cntnode].sz=1;
	tr[cntnode].v[0]=tr[cntnode].m[0][0]=tr[cntnode].m[0][1]=WE[tp];
	tr[cntnode].v[1]=tr[cntnode].m[1][0]=tr[cntnode].m[1][1]=WE[tp^1];
	rt=merge(rt,cntnode);
	return;
}
int main(){
//	freopen("code3.in","r",stdin);
//	freopen("code.out","w",stdout);
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	WE[0].a[0][0]=WE[0].a[0][1]=WE[0].a[1][1]=1; WE[0].a[1][0]=0;
	WE[1].a[0][0]=0; WE[1].a[0][1]=mod-1; WE[1].a[1][0]=1; WE[1].a[1][1]=2;
	add(0);
	cin>>n>>q>>str;
	for(int i=0;i<n;i++)
		if(str[i]=='W') add(0);
		else add(1);
	char c; int l,r,x;
	cout<<tr[rt].m[0][0].a[1][1]<<" "<<tr[rt].m[0][0].a[0][1]<<'\n'; 
	int cntt=0;
	while(q--){
		cin>>str;
		if(str[0]=='A'){
			cin>>c;
			if(c=='W') add(0);
			else add(1);
		}
		else if(str[0]=='F'){
			cin>>l>>r; l++; r++;
			pair<int,int> p1=split(rt,l-1);
			pair<int,int> p2=split(p1.second,r-l+1);
			x=p2.first; tr[x].tagf^=1;
			swap(tr[x].v[0],tr[x].v[1]);
			swap(tr[x].m[0],tr[x].m[1]);
			rt=merge(p1.first,merge(p2.first,p2.second));
		}
		else{
			cin>>l>>r; l++; r++;
			pair<int,int> p1=split(rt,l-1);
			pair<int,int> p2=split(p1.second,r-l+1);
			x=p2.first;
			swap(tr[x].ln,tr[x].rn);
			swap(tr[x].m[0][0],tr[x].m[0][1]);
			swap(tr[x].m[1][0],tr[x].m[1][1]);
			tr[x].tagr^=1;
			rt=merge(p1.first,merge(p2.first,p2.second));
		}
		cout<<tr[rt].m[0][0].a[1][1]<<" "<<tr[rt].m[0][0].a[0][1]<<'\n';
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 5
Accepted
time: 8ms
memory: 45820kb

input:

2000 2000
EEWEEWEEWEEEEEEEEEEEWEWWEWEWEWWEWWEEWWWWWEEWWWWEEEWWEEEEEEWEEWWWEWEEWWWEWWWEEEEEWEEWEEEEEWEWWWWEWEWWEWWWEWWEEWEWEWEEWEEEWEEEEEWWWWWEEWEEWWWWEWEEWWEWEWEWWWWEWEWEEWWWWWWEWWEWEWEWEWWWWWEWWEEEEWWEWEEWEEEWWEWWEEEWEWWEEEEEWEWEWWEWWEEWWWWEWWWEEWEWEWWEWWWWEEWWEEWEEWWWWEWWWWWEWEWWEWWWEWEWEWEWEEWEWW...

output:

236914576 427170560
455958030 792307171
350099908 643944131
30094991 244492279
664330683 672034650
196986454 826231782
811869946 57281060
428509085 286574691
242134678 343855751
575517458 916720058
924999075 813960063
502272180 732435768
429026902 548151478
117159291 713634437
994387081 908426498
11...

result:

ok 2001 lines

Test #2:

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

input:

2000 2000
EEEWEEWEWEEEEWWWWWWEWEEWEEWWWEEEEEWWWEWEWEWEEEWWWEEWWEEWWWWEWWWEEWEEWWWEEEEWEWWWWEWEEEWWEEEWWEWEEEWWEEEWEEWWEEEEEEWWWWWWWWWEEWWWEWWEEEEEEEEWEWWWEWEEEEWEEEEWEWWWWEEEEWEEEEWWEEEWWEWWEEEEEEEWWWWEWEEWEEWEEEWWWWWEEEEEEWEWEWWEWWEWWEWEWWWWWWWEWWEWWEEEWEWWWWEWWWEWWEEWWEEWWWWWWEWWWWWEEEWEWEEEWWWWEW...

output:

6463648 45329706
704854091 442597320
611518326 829511419
169746550 712178861
343598285 645073706
51850478 881313322
758347024 119308585
810197502 2377554
8347627 717938203
387334078 730560576
513033985 905117933
941437898 150747949
655470247 523903222
598663792 674651171
441573667 488014808
5663047 ...

result:

ok 2001 lines

Test #3:

score: 5
Accepted
time: 11ms
memory: 45888kb

input:

2000 2000
WEWWWWWWEWEWEEWWEEEWWWEWEEEWWEWWWWWWWEEWWEWEWEEEWEEEEEEEEWEEEWEWWEWEWEWWEEEEEWWEWWWEWWEWEWWEEWEEEWWEWEWWWEWEEWWWWEEEWEWEEWWWEEWEEEEEEWWWWWEEEWWWEWEWEWEEEWWEWWEWWWWWEWEEEWWWWEEEEWEEEWEWEWWEWWEWEEWEEEWWWEEWWWEEWEWEWEWEWEEWEWEEWWWWEEEWWEWEEWEWWEEWWWWWEWWEWEWEWWWEEEEEEEEEEEWEEEEWEEWEEWWWWEEWWW...

output:

370118869 68690813
515226007 364567815
321309070 771226105
836535077 137549567
825557266 592676526
586020561 400876265
546172140 667508517
949881892 410393758
495806013 112686580
847194282 623388482
564480425 383951352
758536622 22187248
134492891 653514182
237878375 947202223
528832941 884621310
44...

result:

ok 2001 lines

Test #4:

score: 5
Accepted
time: 15ms
memory: 45804kb

input:

2000 2000
WWWEWEWWEEEEWEEWEEWEWWWEWEWEWWWWEEWWWWWEWWEEWWWEEWWEWEWWWEWEEEWWWWWWEWWWEWEWWEEWWEWEEEEEEWWEEWWEEEEEEWWEEWEEEWEWWEEWWEEEWWWWEEEWWEEEWEWEEEWWEEEWWEEEWWWWWWEEEWEEWWEEEEWWEWWEEEEEEWWWEWWEEWEWWWEEEEWWEEEWEWEEEEWEWWWWWEWWWEEWEWEWWWWEWEEWWWEEWWEWEWEWWEEWEEEEWWWEWWEWEEWEEEEEEWEEEWEEEEWWWWEEEEWWWW...

output:

235402133 46717372
503780338 308308218
772158543 569899064
502357027 124712409
981342842 751949499
485455516 876661908
646460084 249933867
888347395 995462419
474758271 420262950
364861313 417481016
254964355 414699082
267901582 760666130
302820744 702265551
337739906 643864972
640560650 347886170
1...

result:

ok 2001 lines

Test #5:

score: 5
Accepted
time: 306ms
memory: 46064kb

input:

100000 100000
WEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWE...

output:

56136314 66655788
66655788 122792102
122792102 189447890
189447890 312239992
312239992 501687882
501687882 813927874
813927874 317371403
317371403 133054924
133054924 450426327
450426327 583481251
583481251 35663225
35663225 619144476
619144476 654807701
654807701 275707824
275707824 930515525
93051...

result:

ok 100001 lines

Test #6:

score: 5
Accepted
time: 555ms
memory: 46064kb

input:

100000 100000
WEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWE...

output:

56136314 66655788
56136314 66655788
66655788 56136314
122792102 66655788
66655788 122792102
66655788 122792102
122792102 189447890
189447890 122792102
122792102 189447890
189447890 122792102
122792102 189447890
189447890 312239992
312239992 501687882
501687882 813927874
813927874 317371403
317371403...

result:

ok 100001 lines

Test #7:

score: 5
Accepted
time: 414ms
memory: 46008kb

input:

100000 100000
WEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWEWE...

output:

56136314 66655788
66655788 122792102
122792102 189447890
189447890 312239992
312239992 501687882
501687882 813927874
813927874 501687882
317371403 813927874
133054924 317371403
450426327 133054924
583481251 450426327
35663225 583481251
619144476 35663225
654807701 619144476
275707824 654807701
93051...

result:

ok 100001 lines

Test #8:

score: 5
Accepted
time: 316ms
memory: 45932kb

input:

100000 100000
EEWWWWWEWEEWEEEWWEEEEEEWEWWEWEWEWWEWEEEWWWEWEWWEWEEEWWEEEWWWEWWEWEEEEEEEWWEWEWEEEWEEWEWWEWWWWEWWWEEEWEWWWWEWEWWEWEWEEWWWEEEEEWEWEWEEEEEWWWWEWEWWEWWEEEWWEEEEEEWEEWWWEWEWWWEWWWEWWWEEWWWWWEWEEWEWWEWWEWWEEWEWWWWEEEEWEEEWEWWEWEEEEWEWWWEWWEEWEWEWWWWWEWWWWEWEEWEWWEWWWEEEWWWEWEWEEWWEEEWEEWEWEE...

output:

463893689 482207361
133609903 435326164
597503592 917533525
63152928 401496533
660656520 320785705
723809448 722282238
786962376 125534418
512527471 847816656
238092566 571854541
750620037 421426844
264903155 270999147
777430626 120571450
44089428 391570597
821520054 512142047
865609482 903712644
90...

result:

ok 100001 lines

Test #9:

score: 5
Accepted
time: 318ms
memory: 45992kb

input:

100000 100000
EEEWWEEWEEWEWEEEWWWEWWWWEEEWWEEEEWWEWWWEEEWWEEWEEEEWWWEEWEWEEWEWEWEEEWEEEEEEEWWWWWEWWEEWEEWWEWEEEWWEWEEWEEEWEWWEEEWWWEWEEWWWWEWWEEWEEEEEWWWEEEWEWWWEWWWWEWWEWWWWWEWWWWWWEWEEWWEEWWWEWEEWEEWWEWEEEWWWWWWWWEWWWWWWWEWEWEWWEEEWEWWEWEWWWEWWEEWEEWEEEWEWEWWWEEWWEEEWWEEWEEWWWWEWWEWWWEWWWWWEEEWEEW...

output:

232304001 75907756
992889884 318082491
755231414 560257226
517572944 802431961
279914474 46362343
42256004 288537078
802841887 530711813
565183417 772886548
369780951 305354008
174378485 836065821
977220372 368533281
153354504 206354749
132330523 574888030
285685027 781242779
418015550 357886456
703...

result:

ok 100001 lines

Test #10:

score: 5
Accepted
time: 311ms
memory: 45996kb

input:

100000 100000
WWWEEWEWWWWEWEEEWWEWWEWWWEWEEEEEEWWEEWWWEWEWEEWEEEEEEWEWEEWWWWEWEEEWWWEEWEEEWWEWEWWEWEEWEEWEWWWEWWEWWEWEEWEWEWEEEWEWEWWEWEEEWEWWWEWEWEWWWWEWEWEWWEWWEEEEEWWWEEEEEWEEEEWWEWWWEWWWWWEWWWWWEWWEWWEWEEWEWEEEWEWWWEEEWWWWWWWEEWEWEWEWEWEWEEWWEEEWWWEEWEWEWWWEWEWWEWWEWEEWEEWWEEWWWEEWWWEWEWWWEWEWWW...

output:

420945641 765038584
287391171 892432660
708336812 659226891
131038100 426021122
551983741 192815353
972929382 957853937
395630670 724648168
816576311 491442399
239277599 258236630
660223240 25030861
82924528 790069445
503870169 556863676
586794697 348688768
92420513 905552444
596290682 464171767
101...

result:

ok 100001 lines

Test #11:

score: 5
Accepted
time: 912ms
memory: 45928kb

input:

100000 100000
WWEEWWWWEEEWWEEWEWWEWEWWEWWEEWWWWEEWEWWEWWEEEWEEEWEWEWWEEEWEWWWEEWEWWWWWWEWWWEWEEEEWWWEEEWEWEWEEWEEEWWWEEEEEWWWEEWWEEWEEWWEWWEEEWEEWWEEWEWWWEWWEEWWEWEWEWWEWWEWWEEEEEEEWWEEWWWEEEWWWWWEEEWWWEWWEEWWEWEWWEEEWEEEEWEWWWEWWEEWEEEEWWEWWEWEEEWEWWWEWWEEWEWWEWWWEWWEWEWWWEWWWEWEWWEWEEEEEWEWEWWWEEW...

output:

875658802 592573622
107467049 537320672
983125851 131649941
92348547 668970613
304992929 22580220
559774284 403514842
814555639 784449464
745131376 570323730
76161451 265915172
988783466 614488749
445885014 266051968
683038847 804863814
901299930 71907187
121316660 337194913
412222592 282172690
6601...

result:

ok 100001 lines

Test #12:

score: 5
Accepted
time: 801ms
memory: 46000kb

input:

100000 100000
WEEEEWWEWEWEWWEEEWWEWEWWWWEWWEEEEWEEEEWEWWWEEEWWWWWEWWWWWWWEWWEEEEWWEEEWEEWEWEEEWWEWEWWEEWEWEEWWEEEEEEEEEEWWWWEWWWWEWWWEEWEEWWWEEEEEEEWEEEWWEWEWWWEWWEEEEWEEWEEWEEEWEEWWWWWWEEEEWEEEEEWEEWEWEEEEEWEWEWEEEWEWEEEEEWEEWEEWEEWEWWEEWEWEEEEEWWEEWEWEEWEEWEWEEWEEEWEEWEWEWWWWWWWWEWEEEEWEEEWEWWEEEW...

output:

203120597 308678726
255563317 282006166
475552576 555331995
228855531 399184286
980402839 243036577
211014017 642220863
439869548 43160796
501804704 568830215
549345256 811098753
52905607 381684615
554710311 950514830
496199602 953313351
375124157 898145865
871323759 853214863
369279008 808283861
86...

result:

ok 100001 lines

Test #13:

score: 5
Accepted
time: 702ms
memory: 45936kb

input:

100000 100000
EEWWWEWWEWEWEEWWWEEWEWWWWEWWWEEWEEWEWEEWWEWWEEEWEWEEWWWEEWWEEWWEEWEEWEEEEWEWWEWEEEWWEEEWEWWEWEEEEEEEEWWWEWEEEEWEEWEWWEWWEWWWWWEWEEWWEWWEWWWWEWWEEEWWWWWWWWWWEEEEWEWWEEEWWEWEWWEEWWWEWEWWEWWWEWEEWEWWEEWWEWEEWEWEEWEWEWWWWWWWWWWEEEWWWEWWEWWEWWEWWEWWWWEEEWWWEWEEEWWEWWWEEWEEEWEWWEWWWEEWEWWWWW...

output:

294324420 215062545
103351065 218239685
333063998 865775288
569553370 221191733
541326116 319271962
790691710 937383211
41812951 557250107
832504661 496388965
232294174 690789064
374340065 892714169
606634239 585258880
838928413 277803591
717305657 500994916
105458468 697918283
822764125 200668846
7...

result:

ok 100001 lines

Test #14:

score: 5
Accepted
time: 585ms
memory: 45992kb

input:

100000 100000
EEWEEWEEEEWWEEWEEEWWEEEEWEEEEEEEWEWWEWWEEEEEEEEWWEEEWEWWWEEEWWEEWWEWEWEEWWWWWWEWEEEWEEEWWEWWWEWEWEWWEEEEEWWWWWEEEWEWEEEEEWWWWWEEEEEWEWWEWWWWWWWWEWEEWEWWEWEWWWWEWEWEWEWWEWEEWWEWEEEWWEWWWWEEEWWEWWEEWWEEEEEEWEEWEEWWWEWWWWEEWWEWWEWEEWWWEWWEEEWEEWWWWEEEEWWEEEWEWWWEWEEWWWEWWEWWEEWEWEEEWWEWWE...

output:

543150472 525576930
902631523 806216968
155976689 583695289
604370339 889096926
54519636 196254210
502913286 501655847
538920249 318554933
910756307 199344037
451432203 517898970
990352452 836453903
531028348 156764483
523136447 993218386
55920442 151738516
586948790 308502999
119732785 465267482
70...

result:

ok 100001 lines

Test #15:

score: 5
Accepted
time: 917ms
memory: 45992kb

input:

100000 100000
WWEEWWWWWEWWWWEEWWEWWEEEEWEWEEWWEEWEWWEEEWWEWWWWWWEEWEEWWEEWWEWEEWWEWWWWWEWEWWEEWEWEWEEWWEEWEEEEEWEEEWWEWWWWWWEEWEEEWWWWEEWEWWEEWEEEEWEWWWWWWWWEWWWEEWWWWEEEEEWEEWEEWEEWEEEEWEWEEWWWEEEWEEEEEEEEEWWWWEEWWWWEWWEWEWEWEEEWEEEEEEEEEWEWWWWWWWWEEWWWEWWEWWWEEWEWWWWEEEEWWWWEEEEEWEWEEWEEEWWEWWWEWE...

output:

738394504 196899806
628252315 480934203
708007509 473282308
338015471 954216511
47778627 429254466
755786136 902536774
813468733 871496311
465034254 401763956
116599775 930275954
604622887 807050782
984730644 730083742
312659278 737561376
917667427 723466314
981557837 538301601
172780314 609494287
8...

result:

ok 100001 lines

Test #16:

score: 5
Accepted
time: 816ms
memory: 45996kb

input:

100000 100000
WEWEEWEEEEEWWWEWEWWWWWWEEEWWEEWWWWWEWEWEWEWWEEWEWEEEEWWEWWWEEWEWWEEEEEEEWWEWWWEEEEWEWEEEEWEWWWWEEWWEEWEEEEWWEWEWWWWWWWEEEWWEWWWWWEWWEEWWWWWEWEWWEEWEWEEEEWEWWWWWWWWWEWEEEEEEWEEWEEEWWEWEEWEWWWEEWEEEWWWEEWEEEWWEEEWEWWWEEEEWEEWWEEWEEEWWWEEEEWWEEWEEWEWWWEWWWEWEEEWEEEEEWEWEEEEEEEWEWEEEWWWWWE...

output:

221881377 64526300
867264922 104966851
895699262 160858486
924133602 216750121
821588511 377608607
224002813 442148058
430544020 52702889
575673161 823359256
331670170 464158708
797643949 571296040
510251131 185938916
222858313 798826145
99553688 290053969
904705569 62913317
657177704 320116308
4862...

result:

ok 100001 lines

Test #17:

score: 5
Accepted
time: 1022ms
memory: 45996kb

input:

100000 100000
EEWEEWWEEWWEEEWEEEEEEWEEWEWWWWEEWEEWEWEEWEEEEWWEWWEWEWEWWWEWWWWEEEEEEWWEEWWWEWWEEWWWEWWEEWWEEWWWEWEEWWEEWWEEWWEEEEEEEEWEWEEWWEEWWWWEWWEEEWWEEWEWEEEWWEEEEEWEEEEEEWEWEWWWEWWWWWWWEWEWEWEWWEWWEEWWEEEWWEEWEWWEEWWEWWWWWWWEWEWWWEEWWWEEWEWEWEEEWWWEEEEEWEEEEEEWEWWWEEWEWEEWEEWWWWEWEEWEWEEWEWWWEW...

output:

453792249 419195457
635509442 125271770
348485242 826289385
871179462 952685220
779885962 969532744
18402734 425925227
851196373 662026212
611299288 697053901
108836443 836708452
693246926 794021273
300391905 215225657
597429151 698686793
300028196 860554027
6083087 412972925
707680681 9903684
20621...

result:

ok 100001 lines

Test #18:

score: 5
Accepted
time: 860ms
memory: 45944kb

input:

100000 100000
WEWEEWWWEWWEEWEEEWEEWEEWWEWEEWEWEWWWEWWEWEWEWEEEWWEEEEWEWWEEEEWWWWEWEEEWEWEWEWWWWWEEWEEWEEWEWEEWEEWWEWWWWEEWEWEEWWWEEWEEWWWWEEWWWEEWWWEEWWWEEWWEEWEEEEWWWEWWWEEEWEWEEEEWWEWWEWEEEWWEEWWWWWWWWEWEEWWWEEEWEWEEWEWEWWWEEEWWWWEWEWEEWWEWWWWWWEWWWWWWEEWWWEEWEWEWWEWEWEWWEEWWWWWEWEEWEWEWWEEWEWWEWW...

output:

762638567 681697179
39169027 823655962
58904035 71249595
781775746 645563360
216062286 731858957
698161470 422590424
545096248 427215848
187484712 978815162
87310597 368180733
396876496 266485042
706442395 164789351
17763941 63093660
327329840 959642322
636895739 857946631
964225579 819344600
602876...

result:

ok 100001 lines

Test #19:

score: 5
Accepted
time: 594ms
memory: 45932kb

input:

100000 100000
WWEWEWWWWEWWEEEEWWEWEEEEWEWEEEWEEEWEWEWWWEEWWWWEWEEEEEWEEEEEWWEWWWWWWWWWEEEEWEEEEEEWEEWEWEWWEEEWWEEWEWWWEEEWEEEWWEEEEWEWWEEWWWEEWEEWEWWEWEWWEEEEEWWWWWWEWEWEEWEWWEEEWWEEWWWWWWEWEWWWEWWEEEWWWEWEEEWWEWWWEWEWWWWWWWEWWWEEEWEEEWEEWEEWWWWEWEWEWWEEEEWWEWWEWEEWWWEWEWEEWEWEWEEWEWEWEWEWEEWEEEEEEW...

output:

74681488 836785835
638623812 915677147
895462570 336542170
672404863 195085270
569623080 531627440
325352021 466137176
289556271 216748375
396593283 584704042
686149554 801452417
278494080 349681938
285839947 251563973
293185814 153446008
390887343 303148159
155715876 867442081
882466549 729808149
6...

result:

ok 100001 lines

Test #20:

score: 5
Accepted
time: 706ms
memory: 45992kb

input:

100000 100000
WEEEEEWWEEWEEEWEWWWWEEWWEEEWWEEEWEEWEEEEWWWEWEWWWEWWEWWEEEEWWEWEWWWWWEWEEEEEEEEWWWWEWWEEEEWWEWWWEWEWEWWWWEWEWWWWEWWWEEEWWEEWEWWEWWWEWEEEEWEWEEEWEWEWWWEEWEEWEWEEWWEEEWEWWWWEWWWEWWEWWWEEWEEEEWEWWWEEEEEEWWEEWEEEWWEEWEEEEWEEWEEEWWWWEEWEWWEWEEEEWEEEWWWWEWEEEWWEWEEWWEEWEEEWWWWEWWEEWEEEEEEEEE...

output:

585679563 527550909
301810803 97943174
184888702 250150555
764009299 13962586
892408347 983785319
771792234 757579416
242483451 785888882
459888418 99762025
271456373 608442296
967785092 643292378
48255 339129176
775700305 755289495
553108002 173205461
597638245 363923008
439206085 558514174
3859997...

result:

ok 100001 lines

Extra Test:

score: 0
Extra Test Passed