QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#786806#9625. 魔弹LinZhengyuAC ✓607ms42764kbC++145.6kb2024-11-26 23:37:172024-11-26 23:37:17

Judging History

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

  • [2024-11-26 23:37:17]
  • 评测
  • 测评结果:AC
  • 用时:607ms
  • 内存:42764kb
  • [2024-11-26 23:37:17]
  • 提交

answer

#include<bits/stdc++.h>
using std::cin;
using std::cout;
using std::pair;
using std::string;

typedef long long lli;

const int P=998244353;
const lli LM=8e18;
inline void LALM(lli&a,const lli b){if((a+=b)>=LM)a%=P;}//b=1e9*1e9
inline void AM(int&a,const int b){if((a+=b)>=P)a-=P;}
inline int AM2(int a,const int b){a+=b;return a>=P?a-P:a;}

inline int qpow(int x,int y){
	int z=1;
	for(;y;x=1ll*x*x%P,y>>=1)if(y&1)
		z=1ll*z*x%P;
	return z;
}
inline int inv(int x){return qpow(x,P-2);}

inline int jm(int x,int y){
	int z=1;
	for(int i=x;i>x-y;--i)
		z=1ll*z*i%P;
	return z;
}

namespace POLY {
//#ModBasic
//#UsefulCalc:qpow,inv
const int L=1<<19,G=3;//L:maxLength G:groot
int nv[L+5],og[L+5];

typedef std::vector<int> Poly;
inline void polyInit(int l){
    nv[1]=1;
    for(int i=2;i<l;++i)
        nv[i]=1ll*(P-P/i)*nv[P%i]%P;
    og[1]=1;
    for(int i=2;i<l;i<<=1){
        int d=qpow(G,(P-1)/(i*2));
        for(int j=i;j<i<<1;j+=2)
            og[j]=og[j>>1],og[j|1]=1ll*og[j]*d%P;
    }
}

inline int eval(const Poly a,int x){
    lli r=0;
    for(int i=0,y=1;i<a.size();++i,y=1ll*y*x%P)
        LALM(r,1ll*a[i]*y);
    return r%P;
}
inline int upl(int l){
    --l;
    l|=l>>1,l|=l>>2,l|=l>>4,l|=l>>8,l|=l>>16;
    return l+1;
}
inline void DIF(Poly&a,int l){
    for(int i=l>>1;i;i>>=1)
        for(int j=0;j<l;j+=i*2)
            for(int k=0;k<i;++k){
                int z=1ll*og[i|k]*(a[j|k]+P-a[j|i|k])%P;
                AM(a[j|k],a[j|i|k]),a[j|i|k]=z;
            }
}
inline void DFT(Poly&a,int l){
    for(int i=1;i<l;i<<=1)
        for(int j=0;j<l;j+=i*2)
            for(int k=0;k<i;++k){
                int z=1ll*og[i|k]*a[j|i|k]%P;
                a[j|i|k]=AM2(a[j|k],P-z),AM(a[j|k],z);
            }
}
inline void PDFT(Poly&a,int l){
    for(int i=0,z=P-(P-1)/l;i<l;++i)a[i]=1ll*a[i]*z%P;
    std::reverse(a.begin()+1,a.end());
}
Poly operator *(Poly a,Poly b){
    int l=a.size()+b.size()-1,ul=upl(l);
    a.resize(ul),b.resize(ul);
    DIF(a,ul),DIF(b,ul);
    for(int i=0;i<ul;++i)a[i]=1ll*a[i]*b[i]%P;
    DFT(a,ul);
    PDFT(a,ul);
    a.resize(l);
    return a;
}
inline Poly polyInv(Poly a){
	int l=a.size(),ul=upl(l);
	a.resize(ul);
	Poly b,c;
	b.resize(1),b[0]=inv(a[0]);
	for(int i=2;i<=ul;i<<=1){
		b.resize(i*2);
		DIF(b,i*2);
		c.resize(i);
		for(int j=0;j<i;++j)c[j]=a[j];
		c.resize(i*2);
		DIF(c,i*2);
		for(int j=0;j<i*2;++j)
			c[j]=(1ll*(P-c[j])*b[j]+2ll)%P*b[j]%P;
		DFT(c,i*2);
		PDFT(c,i*2);
		b.resize(i);
		for(int j=0;j<i;++j)b[j]=c[j];
	}
	b.resize(l);
	return b;
}
inline Poly polyDe(Poly a){
    Poly b(a.size());
    for(int i=0;i<b.size()-1;++i)b[i]=(i+1ll)*a[i+1]%P;
    b[b.size()-1]=0;
    return b;
}
inline Poly TMul(Poly a,Poly b){
	int la=a.size(),lb=b.size(),l=la+lb-1,ul=upl(l);
	a.resize(ul),b.resize(ul);
	std::reverse(b.begin()+1,b.end());
	for(int i=0,z=P-(P-1)/ul;i<ul;++i)b[i]=1ll*b[i]*z%P;
	DIF(a,ul),DIF(b,ul);
	for(int i=0;i<ul;++i)b[i]=1ll*a[i]*b[i]%P;
	DFT(b,ul);
	b.resize(lb);
	return b;
}

const int SN=1<<19;//SN: upl(N)*2

typedef std::vector<int> Vector;
Vector pq[SN+5];

void MPVInit(const Vector&b,int w,int l,int r){
	if(l==r){
		pq[w].resize(2);
		pq[w][0]=1,pq[w][1]=AM2(0,P-b[l]);
		return;
	}
	int mi=l+r>>1;
	MPVInit(b,w*2,l,mi),MPVInit(b,w*2+1,mi+1,r);
	pq[w]=pq[w*2]*pq[w*2+1];
}
void MPVDivide(int w,int l,int r,Poly a,Vector&b){
	a.resize(r-l+1);//?
	if(l==r){b[l]=a[0];return;}
	int mi=l+r>>1;
	MPVDivide(w*2,l,mi,TMul(pq[w*2+1],a),b);
	MPVDivide(w*2+1,mi+1,r,TMul(pq[w*2],a),b);
}
inline Vector multiPointValue(Poly a,Vector b){
	int l=std::max(a.size(),b.size());Vector r(l);
	a.resize(l+1),b.resize(l);//?
	MPVInit(b,1,0,l-1);
	MPVDivide(1,0,l-1,TMul(polyInv(pq[1]),a),r);
	r.resize(b.size());
	return r;
}
void dvd(Poly a[],int l,int r) {
	if(l==r)return;
	int mi=l+r>>1;
	dvd(a,l,mi),dvd(a,mi+1,r);
	a[l]=a[l]*a[mi+1];
}
};
using POLY::multiPointValue;
using POLY::polyDe;
using POLY::Poly;
using POLY::Vector;
using POLY::dvd;

const int N=1e5;

int n,jc;
string s;
int tk[N+5],tp;char c[N+5];

Poly a[N+5],b[N+5];int at,bt;
int ans[N+5];

int main() {
	std::ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);

	POLY::polyInit(POLY::L);

	cin>>n;
	jc=1;for(int i=1;i<=n;++i)jc=1ll*jc*i%P;
	cin>>s;
	for(int i=0;i<s.length();++i)
		if(i==0||s[i]!=c[tp])++tp,tk[tp]=1,c[tp]=s[i];
		else ++tk[tp];
	if(c[1]=='L'&&tp<3||c[1]=='R'&&tp<2) {
		for(int i=1;i<=tp;++i) {
			if(c[i]=='L') {
				for(int j=1;j<tk[i];++j)cout<<0<<' ';
				cout<<jc<<' ';
			}
			else {
				cout<<jc<<' ';
				for(int j=2;j<=tk[i];++j)cout<<0<<' ';
			}
		}
		return 0;
	}
	int i=1+(c[1]=='L'),s=1+(c[1]=='L')*tk[1];
	b[++bt].resize(2),b[bt][0]=P-s,b[bt][1]=1;
	for(;i<tp;s+=tk[i]+tk[i+1],i+=2) {
		a[++at].resize(2),a[at][0]=P-s-tk[i],a[at][1]=1;
		b[++bt].resize(2),b[bt][0]=P-s-tk[i]-tk[i+1],b[bt][1]=1;
	}
	dvd(a,1,at),dvd(b,1,bt);
	b[1]=polyDe(b[1]);
	Vector qv;
	i=1+(c[1]=='L'),s=1+(c[1]=='L')*tk[1];
	qv.emplace_back(s);
	for(;i<tp;s+=tk[i]+tk[i+1],i+=2)
		qv.emplace_back(s+tk[i]+tk[i+1]);
	Vector va=multiPointValue(a[1],qv),vb=multiPointValue(b[1],qv);
	i=1+(c[1]=='L'),s=1+(c[1]=='L')*tk[1];
	for(int j=0;i<tp;i+=2,++j) {
		ans[i]=1ll*jc*va[j]%P*inv(vb[j])%P;
		ans[i+1]=1ll*jc*va[j+1]%P*inv(vb[j+1])%P;
	}
	if(c[1]=='L')ans[1]=ans[2];
	if(c[tp]=='R')ans[tp]=ans[tp-1];
	for(int i=1;i<=tp;++i) {
		if(c[i]=='L') {
			for(int j=1;j<tk[i];++j)cout<<0<<' ';
			cout<<ans[i]<<' ';
		}
		else {
			cout<<ans[i]<<' ';
			for(int j=2;j<=tk[i];++j)cout<<0<<' ';
		}
	}

	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 4ms
memory: 25164kb

input:

2
RL

output:

1 1 

result:

ok single line: '1 1 '

Test #2:

score: 0
Accepted
time: 4ms
memory: 25084kb

input:

4
LLRR

output:

0 24 24 0 

result:

ok single line: '0 24 24 0 '

Test #3:

score: 0
Accepted
time: 3ms
memory: 25532kb

input:

4
RLRL

output:

9 6 6 9 

result:

ok single line: '9 6 6 9 '

Test #4:

score: 0
Accepted
time: 4ms
memory: 25384kb

input:

10
LRLRLLRRRR

output:

1088640 1088640 604800 604800 0 1935360 1935360 0 0 0 

result:

ok single line: '1088640 1088640 604800 604800 0 1935360 1935360 0 0 0 '

Test #5:

score: 0
Accepted
time: 4ms
memory: 25192kb

input:

10
LLRLLRLRLL

output:

0 725760 725760 0 725760 725760 483840 483840 0 1693440 

result:

ok single line: '0 725760 725760 0 725760 725760 483840 483840 0 1693440 '

Test #6:

score: 0
Accepted
time: 7ms
memory: 25448kb

input:

998
RLRLRLRLRLRLRLRLRLRLRLRLRLRLRRLLRRRLRLLRLLRLRLRLLLRLRRLRLRLRLRLRLRLRLRLRLRLRLRLRRLRLLRLRLRLRLRLRLRLRRLRLLRLRLRLRLRLRLRRLRRLRRRLLRLLRLRLLRRLRLLLRLRLRRLRRLRLRLRRLRLRLLRLRLRLRLRLRLRLLRLRLRLRLRLLLRRLLRLRRLRRLRRLRLRLRLRLRLRLRLRLRLRLRLRLLRRLRRRLRRLRLRRLRLRLRLRLRLRLRLLRLLRRLRRLRLLRLRLRLRRLLRLRLRLLRRLRL...

output:

791892921 222105954 222105954 387243673 387243673 858332170 858332170 668690160 668690160 29037702 29037702 344898397 344898397 10138435 10138435 920091431 920091431 680236417 680236417 884390492 884390492 338820980 338820980 508576275 508576275 957551010 957551010 2459479 2459479 0 0 61773050 61773...

result:

ok single line: '791892921 222105954 222105954 ... 632970969 632970969 464724562 '

Test #7:

score: 0
Accepted
time: 11ms
memory: 25276kb

input:

998
RLRLRLRLRLRLRLRLRLRRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRRLRLRLRLRLRLRLRLRLRLRLRLRLRRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRRLRLRLRLRLRLRLRLRRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLR...

output:

439674742 509947875 509947875 815063904 815063904 891776804 891776804 553641803 553641803 13450200 13450200 267859496 267859496 385670319 385670319 882911667 882911667 109331874 109331874 0 128425033 128425033 836729978 836729978 854828800 854828800 123260213 123260213 415537062 415537062 26751346 2...

result:

ok single line: '439674742 509947875 509947875 ... 773862752 498604661 498604661 '

Test #8:

score: 0
Accepted
time: 11ms
memory: 25428kb

input:

1000
LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRL...

output:

255385 255385 948987885 948987885 944375949 944375949 391954880 391954880 918617102 918617102 509797789 509797789 963771001 963771001 168738152 168738152 967324970 967324970 550867915 550867915 149529568 149529568 490172856 490172856 731868859 731868859 286624466 286624466 277467460 277467460 496196...

result:

ok single line: '255385 255385 948987885 948987... 705333897 705333897 531622062 '

Test #9:

score: 0
Accepted
time: 13ms
memory: 25592kb

input:

998
LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLR...

output:

54273261 54273261 171633438 171633438 946148426 946148426 982991957 982991957 138042735 138042735 703892213 703892213 165685072 165685072 890250227 890250227 244374543 244374543 640936104 640936104 169345002 169345002 847600184 847600184 889380235 889380235 648465375 648465375 412924715 412924715 37...

result:

ok single line: '54273261 54273261 171633438 17...38 171633438 54273261 54273261 '

Test #10:

score: 0
Accepted
time: 10ms
memory: 25316kb

input:

999
RLRRLRRRLLLLLLLRRRRLRLLRLRRLLLLRRLLRRRRLRRLRLLRRRLLLLLLRLLRRLRRLLRRRRLLLLRRRLRLRRLLLRRLLLRLLLRRLRRLRRRLLRLRRLRRLLLRLRLLRLRRLLRRRRRLRRRLRRLRLLRLLLLLLLRLLRLLLRRRRLRRLRLLLRRRLRLLRRLRLLRLRLRLLLRRLLLLRLRRRLLLLLLRRLLRLLLRRLRRRRRLLLRLRRLRLLLLRLLLRLLLRRRRLRLRRLRLLLLRLRLRLRLRLLRLLLLLLRRRLLLLLRRLLLLRLLLLR...

output:

831921527 841981814 841981814 0 802033891 802033891 0 0 0 0 0 0 0 0 313870399 313870399 0 0 0 845084145 845084145 0 202490903 202490903 292802290 292802290 0 0 0 0 246685715 246685715 0 0 750008183 750008183 0 0 0 627041700 627041700 0 129985167 129985167 0 414419357 414419357 0 0 0 0 0 0 0 69839104...

result:

ok single line: '831921527 841981814 841981814 ...451543 0 0 73252857 73252857 0 '

Test #11:

score: 0
Accepted
time: 10ms
memory: 25204kb

input:

1000
RRLRRLRLRLLRRRLRLRLRLLLRLLLRLRLLRLRRRLRRRRLLRLLLLRLLRLLRLRLRLLLLRRRRRLRLLLRLLRLRRLRLLLRRLLLLLRLRRRRLRRRLLLLRRLRLLLLLRRRRLLRLRLRLLRRRRRLLRRLRLRLLLLRRRRRLRRLLRRRLRRRRLRLLRRLLRRRLLLLRLLLLRRRRLRLLLLLRRRRLLLRLLRLRLRLRLRLRLRRLLLLRRRLRLLLRLLRRLRRRLLLLLLLLLLLRLLLLLLLRLLLRLRRLRLLLRLLRLLLLRLRLRLRLLRLRLLR...

output:

511795335 0 69779310 69779310 0 739828205 739828205 753376067 753376067 0 701671563 701671563 0 0 212012731 212012731 878780187 878780187 579239850 579239850 0 0 522816863 522816863 0 0 334242623 334242623 863711626 863711626 0 643092447 643092447 851181131 851181131 0 0 561587102 561587102 0 0 0 0 ...

result:

ok single line: '511795335 0 69779310 69779310 ... 186342784 186342784 663982717 '

Test #12:

score: 0
Accepted
time: 8ms
memory: 25520kb

input:

100000
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL...

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 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 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 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 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 single line: '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 215582594 '

Test #13:

score: 0
Accepted
time: 12ms
memory: 25316kb

input:

100000
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

output:

215582594 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 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 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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok single line: '215582594 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 '

Test #14:

score: 0
Accepted
time: 281ms
memory: 33524kb

input:

100000
RLRRLRLRRRLLLLRRLRRLRLRRLLRRRRRLLRLLRLRRLRLLRRRLLRRRRLRLLRRLRLLRRLRRLLLRRLLLLLRLRRLRLLLRRRLRRRLRRLRRRRRLLRRLLLRLRLLLRRLLRLLLRLLRLRRLRLRRRLLLRRLRRRRRRLLLLLLLLLLLRLLRRRLLRRLRRLLRLRLLLRRRLLRRLLLRLLLRRRRLLRLLRLRRRLLLLLRRRRRLLRRRLRLRLRRRLRRRRRLRLRLRLLRRLRRLRRLLRRRLRRRLRLRRRRLRRLLRLLLLLRRRLLLRLRRRL...

output:

655182588 424061777 424061777 0 532898281 532898281 250301765 250301765 0 0 0 0 0 258617217 258617217 0 36972119 36972119 0 990202488 990202488 808928429 808928429 0 0 24205425 24205425 0 0 0 0 0 421610174 421610174 0 84739313 84739313 311210211 311210211 0 731382457 731382457 0 140895153 140895153 ...

result:

ok single line: '655182588 424061777 424061777 ...83051157 883051157 0 981459997 '

Test #15:

score: 0
Accepted
time: 273ms
memory: 33460kb

input:

100000
LLRRRLRLLRLLRLRLLLRLRLLRRLRRRLRLRRRRLLLLLRLRRLRLLRLRLRRLRRLLLLRRRRRLRLRLRRRRLLLLLRLLRLLRRRRRLLRRLRRRRRRRLRLRRRLLRLRRLRRRRRRLLRRLRLRLRLLRLRRLLLRLLLRRRRLLLLLRLRLLRRLLRLLRLLLLRLRLRRRLLRRLLLLLLLLRLLLLLRLLLRLRRRLRRRRRRLRRRLRRLRLRLLRLLRLLRRLRRLLRRRLRLRLRRLRRRLLRRLRLRRLRLRLRLRLRRLRLRRLRRRLLRLRLLRLLR...

output:

0 622368831 622368831 0 0 312222703 312222703 0 644221684 644221684 0 174202506 174202506 871543980 871543980 0 0 935237676 935237676 854058755 854058755 0 524939144 524939144 0 835495707 835495707 0 0 811694651 811694651 8567849 8567849 0 0 0 0 0 0 0 778008990 778008990 273531778 273531778 0 663941...

result:

ok single line: '0 622368831 622368831 0 0 3122...874130 472874130 0 0 915577668 '

Test #16:

score: 0
Accepted
time: 416ms
memory: 40220kb

input:

99999
RLLRLRLLRRLRLLRRLRLRLRRRLRLRRLLRLRLLRLRLRLRLRLLRRLLLRLRLRLLLRRLRLRLRLRLRLRRLRLRLRRLRLRLRLRLLLRRLRLRLRLRLRLRLRLRLRLLRLRRLRLRLRLRLLRLLRLRLRLRRRRLRLRLRLRLRLLLRRLRLRLRLRRLRLRLLRLRLRRLRLLRLRLRLRLRLRRLRLRRLRLLRLRLRLRLLRLRLRLRRLRLRLRLRLRLRLRRLRLRLRLRLRLLLLRLRRLRLRLRLRLLRRLRLRLRLRLRLRLRLRLRLLRLRLRLRLR...

output:

857597950 0 938643316 938643316 546642845 546642845 0 9325804 9325804 0 253386790 253386790 0 284892971 284892971 0 406121179 406121179 126656527 126656527 120800890 120800890 0 0 845318793 845318793 921533342 921533342 0 0 2601538 2601538 197822400 197822400 0 396731107 396731107 562366338 56236633...

result:

ok single line: '857597950 0 938643316 93864331... 942066999 942066999 623799230 '

Test #17:

score: 0
Accepted
time: 600ms
memory: 42400kb

input:

99998
LRLRLRLRLRLRLRLRLRLRLLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRRRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLLRLRLRLRLRLRLRLRLRLRLRLRLRL...

output:

227224847 227224847 688276241 688276241 272269422 272269422 840415038 840415038 709217006 709217006 968282991 968282991 737355553 737355553 593823485 593823485 660168773 660168773 9561283 9561283 0 296353266 296353266 11637670 11637670 944463953 944463953 30674812 30674812 119782681 119782681 392995...

result:

ok single line: '227224847 227224847 688276241 ...43872896 521994131 521994131 0 '

Test #18:

score: 0
Accepted
time: 607ms
memory: 42764kb

input:

99999
LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLR...

output:

657380282 657380282 506001932 506001932 476316674 476316674 769232758 769232758 794446371 794446371 469914731 469914731 877622223 877622223 311033786 311033786 280018681 280018681 466641023 466641023 492736654 492736654 229669458 229669458 589920046 589920046 155576401 155576401 612972851 612972851 ...

result:

ok single line: '657380282 657380282 506001932 ... 137963976 137963976 871464933 '

Test #19:

score: 0
Accepted
time: 597ms
memory: 42724kb

input:

99999
LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLR...

output:

735518182 735518182 261975641 261975641 309450675 309450675 300206665 300206665 354220722 354220722 112132541 112132541 735542082 735542082 599471705 599471705 666404521 666404521 43471739 43471739 721884769 721884769 776311760 776311760 966903300 966903300 156484024 156484024 673316931 673316931 44...

result:

ok single line: '735518182 735518182 261975641 ... 261975641 261975641 735518182 '