QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#739947#9625. 魔弹Kevin5307AC ✓1560ms100232kbC++238.7kb2024-11-13 00:00:522024-11-13 00:01:01

Judging History

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

  • [2024-11-13 00:01:01]
  • 评测
  • 测评结果:AC
  • 用时:1560ms
  • 内存:100232kb
  • [2024-11-13 00:00:52]
  • 提交

answer

//Author: Kevin
#include<bits/stdc++.h>
#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize(2)
//#pragma GCC optimize("O2")
using namespace std;
#define ll unsigned long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
namespace Polynomial
{
	using poly=vector<ll>;
	const ll mod=998244353;
	inline ll red(ll x){return (x>=mod)?(x-mod):x;}
	ll ksm(ll a,ll b)
	{
		ll ans=1;
		while(b)
		{
			if(b&1) ans=ans*a%mod;
			b>>=1;
			a=a*a%mod;
		}
		return ans;
	}
	ll getinv(ll x)
	{
		if(x==1) return 1;
		return getinv(mod%x)*(mod-mod/x)%mod;
	}
	const poly operator +(const poly &a,const poly &b)
	{
		int p=sz(a),q=sz(b);
		int n=max(p,q);
		poly ret(n,0);
		for(int i=0;i<n;i++)
		{
			if(i<p) ret[i]+=a[i];
			if(i<q) ret[i]+=b[i];
			if(ret[i]>=mod) ret[i]-=mod;
		}
		return ret;
	}
	const poly operator -(const poly &a,const poly &b)
	{
		int p=sz(a),q=sz(b);
		int n=max(p,q);
		poly ret(n,0);
		for(int i=0;i<n;i++)
		{
			if(i<p) ret[i]+=a[i];
			if(i<q) ret[i]+=mod-b[i];
			if(ret[i]>=mod) ret[i]-=mod;
		}
		return ret;
	}
	ll gpw[20][1001000],rgpw[20][1001000];
	poly operator *(poly a,poly b)
	{
		if(min(sz(a),sz(b))<=100)
		{
			int add=0;
			while(sz(b)%8)
			{
				b.pb(0);
				add++;
			}
			poly ret(sz(a)+sz(b)-1);
			for(int i=0;i<sz(a);i++)
			{
				for(int j=0;j<sz(b);j+=8)
				{
					ret[i+j]=(ret[i+j]+a[i]*b[j])%mod;
					ret[i+j+1]=(ret[i+j+1]+a[i]*b[j+1])%mod;
					ret[i+j+2]=(ret[i+j+2]+a[i]*b[j+2])%mod;
					ret[i+j+3]=(ret[i+j+3]+a[i]*b[j+3])%mod;
					ret[i+j+4]=(ret[i+j+4]+a[i]*b[j+4])%mod;
					ret[i+j+5]=(ret[i+j+5]+a[i]*b[j+5])%mod;
					ret[i+j+6]=(ret[i+j+6]+a[i]*b[j+6])%mod;
					ret[i+j+7]=(ret[i+j+7]+a[i]*b[j+7])%mod;
				}
			}
			while(add--) ret.pop_back();
			return ret;
		}
		const ll g=3;
		int len=sz(a)+sz(b);
		int m=1;
		while(m<sz(a)+sz(b)) m*=2;
		a.resize(m);
		b.resize(m);
		vector<int> rev(m);
		for(int i=0;i<m;i++)
			rev[i]=(rev[i>>1]>>1)|((i&1)*(m>>1));
		for(int i=0;i<m;i++)
			if(rev[i]<i)
			{
				swap(a[i],a[rev[i]]);
				swap(b[i],b[rev[i]]);
			}
		for(int i=1;i<m;i<<=1)
		{
			for(int j=0;j<m;j+=(i<<1))
			{
				for(int k=0;k<i;k++)
				{
					ll g0=gpw[__lg(i)][k];
					{
						ll x=a[j+k],y=g0*a[i+j+k]%mod;
						a[j+k]=red(x+y);
						a[i+j+k]=red(x+mod-y);
					}
					{
						ll x=b[j+k],y=g0*b[i+j+k]%mod;
						b[j+k]=red(x+y);
						b[i+j+k]=red(x+mod-y);
					}
				}
			}
		}
		for(int i=0;i<m;i++)
			a[i]=a[i]*b[i]%mod;
		for(int i=0;i<m;i++)
			if(rev[i]<i)
				swap(a[i],a[rev[i]]);
		for(int i=1;i<m;i<<=1)
		{
			for(int j=0;j<m;j+=(i<<1))
			{
				for(int k=0;k<i;k++)
				{
					ll x=a[j+k],y=rgpw[__lg(i)][k]*a[i+j+k]%mod;
					a[j+k]=red(x+y);
					a[i+j+k]=red(x+mod-y);
				}
			}
		}
		ll val=getinv(m);
		for(int i=0;i<m;i++)
			a[i]=a[i]*val%mod;
		a.resize(len-1);
		return a;
	}
	void init()
	{
		for(int i=0;i<18;i++)
		{
			ll gn=ksm(3,(mod-1)/(1<<i)/2);
			ll rgn=getinv(gn);
			ll tmp1=1,tmp2=1;
			for(int j=0;j<(1<<i);j++)
			{
				gpw[i][j]=tmp1;
				rgpw[i][j]=tmp2;
				tmp1=tmp1*gn%mod;
				tmp2=tmp2*rgn%mod;
			}
		}
	}
	poly deriv(poly p)
	{
		for(int i=0;i<sz(p);i++)
			p[i]=p[i]*i%mod;
		p.erase(p.begin());
		return p;
	}
	poly integ(poly p)
	{
		p.insert(p.begin(),0);
		for(int i=0;i<sz(p);i++)
			p[i]=p[i]*ksm(i,mod-2)%mod;
		return p;
	}
}
using namespace Polynomial;
int n;
string s;
ll inv[200200],rfact[200200];
ll ans[100100];
ll wl[100100],wr[100100];
using PointValue=vector<ll>;
PointValue evaluate(PointValue pv,int l,int r)
{
	int n=sz(pv);
	if(l<sz(pv)&&r>=0)
	{
		PointValue seg1,seg2,seg3;
		if(l<0) seg1=evaluate(pv,l,0);
		for(int i=max(l,0);i<=min(n-1,r);i++)
			seg2.pb(pv[i]);
		if(r>=sz(pv)) seg3=evaluate(pv,sz(pv),r);
		PointValue ans;
		for(auto x:seg1) ans.pb(x);
		for(auto x:seg2) ans.pb(x);
		for(auto x:seg3) ans.pb(x);
		return ans;
	}
	for(int i=0;i<n;i++)
	{
		pv[i]=pv[i]*rfact[n-1-i]%mod*rfact[i]%mod;
		if((n-i-1)&1) pv[i]=red(mod-pv[i]);
	}
	poly f(n+r-l);
	for(int j=0;j<sz(f);j++)
		f[j]=getinv(l-n+1+j);
	poly h=pv*f;
	ll value=1;
	for(int j=0;j<n;j++)
		value=value*(l-j)%mod;
	PointValue ret;
	for(int j=l;j<=r;j++)
	{
		ret.pb(h[n-1+j-l]*value%mod);
		value=value*(j+1)%mod*getinv(j-n+1)%mod;
	}
	return ret;
}
PointValue extend(PointValue pv,int n){return evaluate(pv,0,n-1);}
PointValue merge(PointValue A,PointValue B)
{
	int n=sz(A)+sz(B)-1;
	A=extend(A,n);
	B=extend(B,n);
	for(int i=0;i<n;i++)
		A[i]=A[i]*B[i]%mod;
	return A;
}
PointValue solveL(int l,int r)
{
	if(l==r)
	{
		if(s[l]=='L')
			return PointValue{red(mod-l+1),red(mod+2-l)};
		return PointValue{red(mod-l),red(mod+1-l)};
	}
	int mid=(l+r)/2;
	auto L=solveL(l,mid);
	auto R=solveL(mid+1,r);
	int have=0;
	for(int i=mid+1;i<=r;i++)
		if(s[i]=='L')
			have=1;
	if(have)
	{
		PointValue LR=evaluate(L,mid+1,r);
		for(int i=0;i<sz(LR);i++)
			wl[i+mid+1]=wl[i+mid+1]*LR[i]%mod;
	}
	if(r==n-1)
		return PointValue{1};
	return merge(L,R);
}
PointValue solveR(int l,int r)
{
	if(l==r)
	{
		if(s[l]=='R')
			return PointValue{l+1,l};
		return PointValue{l,red(l+mod-1)};
	}
	int mid=(l+r)/2;
	auto L=solveR(l,mid);
	auto R=solveR(mid+1,r);
	int have=0;
	for(int i=l;i<=mid;i++) if(s[i]=='R') have=1;
	if(have)
	{
		PointValue RL=evaluate(R,l,mid);
		for(int i=0;i<sz(RL);i++)
			wr[i+l]=wr[i+l]*RL[i]%mod;
	}
	if(!l)
		return PointValue{1};
	return merge(L,R);
}
char buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
void print(long long x) {
    if(x>9) print(x/10);
    *O++=x%10+'0';
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	init();
	rfact[0]=1;
	for(int i=1;i<100100;i++)
	{
		inv[i]=ksm(i,mod-2);
		rfact[i]=rfact[i-1]*inv[i]%mod;
	}
	cin>>n>>s;
	for(int i=0;i<n;i++)
		wl[i]=wr[i]=1;
	solveL(0,n-1);
	solveR(0,n-1);
	for(int i=0;i<n;i++)
		wl[i]=wl[i]*rfact[i+1]%mod;
	for(int i=0;i<n;i++)
		wr[i]=wr[i]*rfact[n-i]%mod;
	for(int i=0;i<=n;i++)
		if((!i||s[i-1]=='L')&&(i==n||s[i]=='R'))
		{
			ll ways=1;
			if(i) ways=ways*wl[i-1]%mod;
			if(i<n) ways=ways*wr[i]%mod;
			if(i)
				ans[i-1]=(ans[i-1]+ways)%mod;
			if(i<n)
				ans[i]=(ans[i]+ways)%mod;
		}
	ll fact=1;
	for(int i=1;i<=n;i++) fact=fact*i%mod;
	for(int i=0;i<n;i++)
	{
		print(ans[i]*fact%mod);
		*O++=' ';
	}
	fwrite(obuf,O-obuf,1,stdout);
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 11ms
memory: 85576kb

input:

2
RL

output:

1 1 

result:

ok single line: '1 1 '

Test #2:

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

input:

4
LLRR

output:

0 24 24 0 

result:

ok single line: '0 24 24 0 '

Test #3:

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

input:

4
RLRL

output:

9 6 6 9 

result:

ok single line: '9 6 6 9 '

Test #4:

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

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: 8ms
memory: 87872kb

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: 11ms
memory: 87896kb

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: 17ms
memory: 83512kb

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: 19ms
memory: 85688kb

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: 11ms
memory: 90012kb

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: 19ms
memory: 83624kb

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: 7ms
memory: 89716kb

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: 1257ms
memory: 95656kb

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: 1205ms
memory: 95356kb

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: 1551ms
memory: 93668kb

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: 1550ms
memory: 91228kb

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: 1559ms
memory: 100232kb

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: 1558ms
memory: 93972kb

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: 1559ms
memory: 91380kb

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: 1560ms
memory: 95528kb

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 '