QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#205889#7559. Bocchi the Rockucup-team1447#AC ✓334ms43096kbC++145.7kb2023-10-07 17:44:492023-10-07 17:44:49

Judging History

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

  • [2023-10-07 17:44:49]
  • 评测
  • 测评结果:AC
  • 用时:334ms
  • 内存:43096kb
  • [2023-10-07 17:44:49]
  • 提交

answer

#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ull unsigned long long
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	if(f)x=-x;return x;
}
 
#define mod 998244353
struct modint{
	int x;
	modint(int o=0){x=o;}
	modint &operator = (int o){return x=o,*this;}
	modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
	modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}
	modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}
	modint &operator ^=(int b){
		modint a=*this,c=1;
		for(;b;b>>=1,a*=a)if(b&1)c*=a;
		return x=c.x,*this;
	}
	modint &operator /=(modint o){return *this *=o^=mod-2;}
	friend modint operator +(modint a,modint b){return a+=b;}
	friend modint operator -(modint a,modint b){return a-=b;}
	friend modint operator *(modint a,modint b){return a*=b;}
	friend modint operator /(modint a,modint b){return a/=b;}
	friend modint operator ^(modint a,int b){return a^=b;}
	friend bool operator ==(modint a,int b){return a.x==b;}
	friend bool operator !=(modint a,int b){return a.x!=b;}
	bool operator ! () {return !x;}
	modint operator - () {return x?mod-x:0;}
	bool operator <(const modint&b)const{return x<b.x;}
};
inline modint qpow(modint x,int y){return x^y;}

vector<modint> fac,ifac,iv;
inline void initC(int n)
{
	if(iv.empty())fac=ifac=iv=vector<modint>(2,1);
	int m=iv.size(); ++n;
	if(m>=n)return;
	iv.resize(n),fac.resize(n),ifac.resize(n);
	For(i,m,n-1){
		iv[i]=iv[mod%i]*(mod-mod/i);
		fac[i]=fac[i-1]*i,ifac[i]=ifac[i-1]*iv[i];
	}
}
inline modint C(int n,int m){
	if(m<0||n<m)return 0;
	return initC(n),fac[n]*ifac[m]*ifac[n-m];
}
inline modint sign(int n){return (n&1)?(mod-1):(1);}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define poly vector<modint>
const modint G=3,Ginv=modint(1)/3;
inline poly one(){poly a;a.push_back(1);return a;}
vector<int>rev;
int rts[2100000];
inline int ext(int n){
	int k=0;
	while((1<<k)<n)++k;return k; 
}
inline void init(int k){
	int n=1<<k;
	rts[0]=1,rts[1<<k]=qpow(31,1<<(21-k)).x;
	Rep(i,k,1)rts[1<<(i-1)]=1ull*rts[1<<i]*rts[1<<i]%mod;
	For(i,1,n-1)rts[i]=1ull*rts[i&(i-1)]*rts[i&-i]%mod;
}

void ntt(poly&a,int k,int typ){
	int n=1<<k;
	static ull tmp[2100000];
	for(int i=0;i<n;++i)tmp[i]=a[i].x;
	if(typ==1){
		for(int l=n>>1;l>=1;l>>=1){
			ull*k=tmp;
			for(int*g=rts;k<tmp+n;k+=(l<<1),++g){
				for(ull*x=k;x<k+l;++x){
					int o=x[l]%mod*(*g)%mod;
					x[l]=*x+mod-o,*x+=o;
				}
			}
		}
		for(int i=0;i<n;++i)a[i].x=tmp[i]%mod;
	}else{
		for(int l=1;l<n;l<<=1){
			ull*k=tmp;
			for(int*g=rts;k<tmp+n;k+=(l<<1),++g){
				for(ull*x=k;x<k+l;++x){
					int o=x[l]%mod;
					x[l]=(*x+mod-o)*(*g)%mod,*x+=o;
				}
			}
		}
		int iv=qpow(n,mod-2).x;
		for(int i=0;i<n;++i)a[i].x=tmp[i]%mod*iv%mod;
		reverse(a.begin()+1,a.end());
	}
}
 
poly operator +(poly a,poly b){
	int n=max(a.size(),b.size());a.resize(n),b.resize(n);
	For(i,0,n-1)a[i]+=b[i];return a;
}
poly operator -(poly a,poly b){
	int n=max(a.size(),b.size());a.resize(n),b.resize(n);
	For(i,0,n-1)a[i]-=b[i];return a;
}
poly operator *(poly a,modint b){
	int n=a.size();
	For(i,0,n-1)a[i]*=b;return a;
} 
poly operator *(poly a,poly b){
	if(!a.size()||!b.size())return {};
	if((int)a.size()<=32 || (int)b.size()<=32){
		poly c(a.size()+b.size()-1,0);
		for(int i=0;i<a.size();++i)for(int j=0;j<b.size();++j)c[i+j]+=a[i]*b[j];
		return c; 
	}
	int n=(int)a.size()+(int)b.size()-1,k=ext(n);
	a.resize(1<<k),b.resize(1<<k);
	ntt(a,k,1),ntt(b,k,1);
	For(i,0,(1<<k)-1)a[i]*=b[i];
	ntt(a,k,-1),a.resize(n);return a;
}

poly Tmp;
poly pmul(poly a,poly b,int n,bool ok=0)
{
	int k=ext(n);
	a.resize(1<<k),ntt(a,k,1);
	if(!ok) b.resize(1<<k),ntt(b,k,1),Tmp=b;
	For(i,0,(1<<k)-1)a[i]*=Tmp[i];
	ntt(a,k,-1),a.resize(n);
	return a;
}

#define maxn 200005
#define inf 0x3f3f3f3f

int n;
int s[maxn][2],p[maxn][2];

struct mat{
	poly f[2][2];
	void resize(int n){For(i,0,1)For(j,0,1)f[i][j].resize(n);}
	void print(){
		For(i,0,1)For(j,0,1){
			for(auto x:f[i][j])cout<<x.x<<" ";
			cout<<"\n";
		}
	}
};
mat operator *(mat a,mat b){
	mat c;
	int mx=0;
	For(i,0,1)For(k,0,1)For(j,0,1)mx=max(mx,(int)a.f[i][k].size()+(int)b.f[k][j].size()-1);
	int k=ext(mx); init(k);
	For(i,0,1)For(j,0,1){
		a.f[i][j].resize(1<<k),b.f[i][j].resize(1<<k),c.f[i][j].resize(1<<k);
		ntt(a.f[i][j],k,1),ntt(b.f[i][j],k,1);
	}
	For(x,0,1)For(y,0,1)For(z,0,1)
		For(i,0,(1<<k)-1)c.f[x][y][i]+=a.f[x][z][i]*b.f[z][y][i];
	For(i,0,1)For(j,0,1){
		ntt(c.f[i][j],k,-1),c.f[i][j].resize(mx);
		while(c.f[i][j].size()>1&&!c.f[i][j].back().x)c.f[i][j].pop_back();
	}
	return c;
}

mat t[maxn];
mat solve(int l,int r){
	if(l==r)return t[l];
	int mid=l+r>>1;
	return solve(l,mid)*solve(mid+1,r);
}

signed main()
{
	
	n=read();
	string ops;
	cin>>ops;
	// arc-poi-arc-poi
	For(i,1,n){
		s[i][0]=(ops[(i-1)*2]=='Y'||ops[(i-1)*2]=='?');
		s[i][1]=(ops[(i-1)*2]=='P'||ops[(i-1)*2]=='?');
		p[i][0]=(ops[i*2-1]=='B'||ops[i*2-1]=='?');
		p[i][1]=(ops[i*2-1]=='R'||ops[i*2-1]=='?');
	}
		For(i,1,n){
			int v=i+1; if(v>n)v=1;
			For(j,0,1){
				if(s[v][j]){
					t[i].f[j][j]={0,p[i][0]+p[i][1]};
					t[i].f[!j][j]={p[i][1]&&(!j),p[i][0],p[i][1]&&(j)};
				}
			}
		}
	mat res=solve(1,n);
//	for(auto x:res.f[0][0])cout<<x.x<<" ";cout<<"\n";
//	for(auto x:res.f[1][1])cout<<x.x<<" ";cout<<"\n";
	poly qwq=res.f[0][0]+res.f[1][1];
	qwq.resize(n+1);
	cout<<qwq[n].x;
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 29360kb

input:

2
????

output:

12

result:

ok 1 number(s): "12"

Test #2:

score: 0
Accepted
time: 0ms
memory: 28804kb

input:

3
??YR?B

output:

4

result:

ok 1 number(s): "4"

Test #3:

score: 0
Accepted
time: 0ms
memory: 28264kb

input:

5
YBYRPBYRYB

output:

0

result:

ok 1 number(s): "0"

Test #4:

score: 0
Accepted
time: 0ms
memory: 29264kb

input:

10
PRPBPRPRPRPBYB?R?BY?

output:

3

result:

ok 1 number(s): "3"

Test #5:

score: 0
Accepted
time: 0ms
memory: 29400kb

input:

10
?R?R?BYB?R?R?B?B?BYR

output:

96

result:

ok 1 number(s): "96"

Test #6:

score: 0
Accepted
time: 0ms
memory: 28108kb

input:

10
YRPRYRY???P?YB?BYRY?

output:

32

result:

ok 1 number(s): "32"

Test #7:

score: 0
Accepted
time: 5ms
memory: 29388kb

input:

10
PBYBPRPBYRPBYRYBPRPB

output:

0

result:

ok 1 number(s): "0"

Test #8:

score: 0
Accepted
time: 0ms
memory: 28228kb

input:

10
PBPRPRYBYRYRYB?B?RYB

output:

0

result:

ok 1 number(s): "0"

Test #9:

score: 0
Accepted
time: 0ms
memory: 28544kb

input:

10
PRP?PBPRYR??Y?YRPB?R

output:

12

result:

ok 1 number(s): "12"

Test #10:

score: 0
Accepted
time: 0ms
memory: 29092kb

input:

10
?RYB??P??B?B?B???RPR

output:

416

result:

ok 1 number(s): "416"

Test #11:

score: 0
Accepted
time: 194ms
memory: 38364kb

input:

50000
YBPBYRPRPRPRPBPRPBPBPBYRPRPBPBYRPBPRYBYBPBPBPRPBPBYRYBYRPBYRYRPBYRYRYRPBYBYRPBPBYBYBPBYRPBPBYBYBYRPBPRYBPBYBPRPRYBPRPBYBPRPBYRPBYBPRYBPBPBYRYBYBYBPRYBYRPRPRPRPRYRYBPBPBPBPRPRYBYRYBPRPRPRPBYBPBPRYRPRPBYRPBYRYRPBYBYBPBYRYRPBPRYBPRYBPBPBYRPBPBYBYBPRPBYBYBYRYRPBPRPRPRPRPRYBPBPBPRYBYRPRPRYBYRPRPBYR...

output:

0

result:

ok 1 number(s): "0"

Test #12:

score: 0
Accepted
time: 189ms
memory: 36480kb

input:

50000
YRPBPBYRYRYRYBYBYRPBPBPBPBPBYRYBPBPRYBPBYRYRPRYBYBYBYRPRPBPBPRYRPBYBYBPBYRYRPRPBPBPBPRYBYBYRYRPRPRYBPRPBYRPBPRYRPRYBPRYBYBYRYRYBYRYRYBYRPBPBPBYBPBPRPBPRYRPRYBYBPBPRPBPBPRPRPBYRYRPBPBPBYRPBYBYBYRPBPRPBPRYBPRPRYBPRPBPBYRYRYRYBYRPRPRYBYBYBPBPRPBPRYRYRPRPRPBPBPRPRPBYBYRPRPRPBYBYRPBYBPRPRPRPRPRPBPB...

output:

0

result:

ok 1 number(s): "0"

Test #13:

score: 0
Accepted
time: 189ms
memory: 34636kb

input:

50000
PRPRYBPBYBYBPBYRPBYRYBPBPBPRPRPBYBYRPRPRPRPRPRYRYBYRPBPBPRYRPRPBPRPBPRPRPRPBYRYRYRPBYBYRYRPRPRPRPRYBYBYBYBPBPRPBPBPRYRPRYRPRPRYRPRPBPBYRYBPRPRYRPBPBYBYBPBYRPBPRYRPRYRYBPBPBPRPBPRPRPRYBPBPBYBYBPRYRPRYRPBYRYBYRYRPBYBPBPRPRYRPRYBYRPRPRYBYBYBPBYRYRYRYRYRYRPBYBYRYRYBYRPRYRPBPBYBYRYBPBYBPRYBPBYRYBPR...

output:

0

result:

ok 1 number(s): "0"

Test #14:

score: 0
Accepted
time: 182ms
memory: 35500kb

input:

50000
YRPRPBPRYRYRPRYBPBYRPRPBYRYRYRPBPBYRPRYBYBYBPRYRPBPRPBPBYRPRPRPBPBYBYBPRPRPRYRYRYBYRPBYBPBPRYBPRYBYBYBPBYBYBPBPBPRYRPRPBYRYBYRPRYBYRPRYRPRPRYRPBYRYRYBYRYRPRYRYRPBPRPBYRYRPBYRPBPBPBPRPBYBYBPRYBPBPBYRYRYBYRPRPBPRYBPRPBYRPBYBYBPBPRPBYRYRPRPBPRPBPBYRPRPBYRPRPRYRYRPBYBYBPBPBYBPBYBYRYBYRPBPBPBPRYRPB...

output:

0

result:

ok 1 number(s): "0"

Test #15:

score: 0
Accepted
time: 193ms
memory: 35476kb

input:

50000
YBPBYRPRYRPRPBPBYBYRPBYRPBPRPRPBPBPBYRYBYRPBYRYRPBYRPRPRYBPRYRYBYBPRPRYBYBPRPRPRYRPRYBPRPBYRPBYRPBYRPRPBPBPRPBPBYRYBPRPBPBPBPBYRYRPRPRYBYRPRYBYBYBYBYRYRPBPRYRYRPRYBPRPBPRPRPRPRPBPRPBYBPBPBPBYRPBYBPBPRPBYRPRPRYRYBYRPRPBPRYBYRPBPRPBPRYRPRYBYRYBYBPRPRPRPBYRPBPBYRYRPBPRYBPRYBPRYBPRYBYRPBYBPBPBYRPR...

output:

0

result:

ok 1 number(s): "0"

Test #16:

score: 0
Accepted
time: 20ms
memory: 29772kb

input:

5000
PR?BPB?BY?PRY??RPB?R??YBY?P?YRPBYBPRP?YBYBYRPRPB?BPBPR?RYR??Y??RYR?BPRYR?RPRP?Y?PRY?Y?YB??PBYRYR?RPB?BPB?BY?P?Y?YBY??RPB?BPRPBY???PRP?YB?R?RP?PR?BPB???R?B?RP?PBYB?BPRYBP?P??B?RPRP???P???PRYB?RYRP?Y??RPR?BP?PR?BPBPRYR?B??PB??YBPB?B?BY?YB?RY?PR?RYB???BYBP?Y??RYRYB?RYBYBPBYRYBP?YBYR?RPBYBY?YRP??R?...

output:

101508706

result:

ok 1 number(s): "101508706"

Test #17:

score: 0
Accepted
time: 16ms
memory: 28952kb

input:

5000
Y?P?PBYBYBPBYB?RYBPRPB?B??YRY??RP?PB??P??BYR?B?BP??R?R?R?BYBP??BY?Y?PBY?Y?YR?RY?PRPR?R?RPR?RPR?BYR?B?B?RPRPR?RP?Y?YRP?Y??RYB????YRY?YR?BP?YB?B??Y??B?RPBYR?RP????B?RPR??????P?PRPR?RP?PR?????BP?P?YB?BYRP?PBP?YBYB?RPR?R?B?BYRYR?RPBPBY??BYBPRYRPBPB?R?RPR?BYBP?YRY?PR?BPR?RY????BYBYB?RYRP???Y???PBY?Y...

output:

748282195

result:

ok 1 number(s): "748282195"

Test #18:

score: 0
Accepted
time: 20ms
memory: 29008kb

input:

5000
P?PRPRPBP??RYB??YBPBYRYB?BP?YB?B?BY??R?BYRP??BPRY?YBYB?RY????B??????PB?RP?P??R?BPB?BY?PR?RPBPBPR?BY?YB?BYBYRYBYRYBY?Y??RP?YR?R?R?BY?PBY??RYBPBYBYBY?PBY?P?YB?RYR???RY?YBY?YRYRY?PBY?P?PBYRPRY?PBP???PBYRPRY?Y?P?P?Y?PR???B?B?RP???PBY?P?PR???BP?PR????P?YB??YR??YRYBYR?B?BP??BPB??P?Y?PRYRY?YB??YR?RY?Y...

output:

24097861

result:

ok 1 number(s): "24097861"

Test #19:

score: 0
Accepted
time: 23ms
memory: 29344kb

input:

5000
??PBPRYBPR??PRP?PRYBY???P?YRPBYBY?YR?RYR??Y?P?YRPR?BPBY?PRPRYB?RYBY?P?????YBPBYBY?Y??BY?PB???BP?P?Y???YR??YBP???YRYB?BPBPRP???PRY??B???BPB???R?RP?PB???BYRP?YB?BP??RP?PBYRPRPR??P??RY????B?????RP?YBYBPRYBYB?RYRYBP??RPB??YRPBY?PBPBP?YRYBPR?BPRYBPB???BYR?RY?PB?RYRY??BYRP?Y?YRP?PRPR????Y?PRPRYBP?YBP...

output:

447561693

result:

ok 1 number(s): "447561693"

Test #20:

score: 0
Accepted
time: 20ms
memory: 28932kb

input:

5000
P?P?P??????BPR?RY?PR??Y?Y??BPR??PB?B??PRP?YB???RPRPRPBY??R??PRYBYR?RPR?BP??R?B?RYRPRP??B?BYRY??R?RP???P?PRP??RY??RY?YBY???????P?Y?PBPRYBPRYRY?P?PB?BPR??P?Y?Y?Y?PR?RPB??Y??BYRP?PRPRY??R?RYBPR??YBP??B?RPRYBPR?BP??BYBYBPRYRPBPRPRY?Y?YBYRPBP?PB??Y?P??????R?BPBYR???BPR?B?R???BYR?BP?P?Y?YRY?PR??YBYB?...

output:

987042679

result:

ok 1 number(s): "987042679"

Test #21:

score: 0
Accepted
time: 17ms
memory: 28468kb

input:

5000
PRPBPRPRYRPRPBYBPBPBYRPBPBPBYRYRYBPBYRPRYBPBPRYBPBYRPRYBYRYRPBPBPBPBYRPBYRYBYRPRYBPBPBPRYBPRYBYBPRPBPBYRYBPRPBYRYRPRYBPRPRPBYRPBYRYRPRPRYRYRYBYBPBPBPBPRPRPBPRPRYRPBYRYRYRPBPRPRYRPRPBYBYBPBPRPRYRPBPRYBPRYBPRPRYRPRYRPBPRYBPRPRYBYRPBYRPRYBPRPRYBYRPRYRYBPRYBPRPBPRPRPRYBYRYRYRYRPBPRPBPRPBPRPBPRYRYBY...

output:

0

result:

ok 1 number(s): "0"

Test #22:

score: 0
Accepted
time: 23ms
memory: 29620kb

input:

5000
PRYRYBPBPRYRYRYRPBPBYBYRPBPBYRPRPRYBYRPRYRPBPRYBPBYRPRYRYRYBPBPBYBPBYBPBYRYRYRYRYBYRPRPBYRYBPRYBYBPRPRPBYRYRYRPBYBPBPRPRYRPRPBPRYBYBPBPBYBPBPBPRPBYRYRYRYRPRYBYBPBYBYBPBYBYRPRYRPRPRYBYRYBYRYRYBYBYRPBPRYRYRPRPRPRPRYRPRYRYRPBYBYRPBYBPBPRYBPBYBPBPRYRYRPBPRPRPBPRYRPRYBPBYRPRYBPBYRYBPRPRYRYBYBPRPBYBP...

output:

0

result:

ok 1 number(s): "0"

Test #23:

score: 0
Accepted
time: 20ms
memory: 29872kb

input:

5000
PBYRYRYBYBPBYBYBPBYBYRPRYBYRPRPBYRYBPRYBPRPRYRYRPBYRYRPRYRYBPBYBPBPRPBPRPBPBP?YRPBYBYBPRPRPBPRYRPRYBPRYRYBYRPRYBYBPBYRPBPBYBYRYBPRPBYRYBPBYBYRYRYRPRPRYBYBPRYRPRYBYBYBPRYBPBYRYBPBPRPRPBYBYRYBYRPRYBYBYBYBYBPBYRPRPRPRPRYBYRPRYRYRYBYRPBYRPBPRPRYBPBYBYRPRYBPRYBPRPRPRPBYRPRPBYRYBY?PRYRYRYBPRYRYBYRYBY...

output:

172032

result:

ok 1 number(s): "172032"

Test #24:

score: 0
Accepted
time: 20ms
memory: 29460kb

input:

5000
????YRPB??PB??Y?Y??R??P?PRY?P??B??PBPBP???PRP??RY??RP?YRYB?R?BY?P??B?B??Y??R?RYRYRP???P?YBPR?R????YBP???P????R?R?BPR??Y?Y?YBP?Y??RY???PR??????P?P?Y??B?R?????B??Y?Y??BY??B?B???RYR???R?RY??RP?PR?RY?PB??Y?P?P???P??B?R??YR?BYRY??????R??Y??RYRPBYR??Y?P?P??B?RP?Y??B?BPBP?P???Y??B?RY?YBYB?RYRYRYBYB???...

output:

589400951

result:

ok 1 number(s): "589400951"

Test #25:

score: 0
Accepted
time: 20ms
memory: 29748kb

input:

5000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

312356960

result:

ok 1 number(s): "312356960"

Test #26:

score: 0
Accepted
time: 199ms
memory: 35984kb

input:

50000
YR?BPR?BP??B??YBY?PRY?PRYB??PB?BPBY??R???RPR??Y?Y???PR???BPBPRPRY?Y?P?Y?P?YR??YR?RP?YRP??B?B???R??YR?BPR?B?R?R??Y?YBYRPR?BPBPRPRPB??YBPR??PR??Y??RYBY??RPRPB??YBPR??PBY?PBPBPRPRPRYRYB??YR?BYRP?P??RYR?R?R?RPBP?Y?YR??YBYR??YRYR???BPRPR???BP??B?BPBYBYBYR?B?RPRPBP?P?YBPB?R?BPBPR?BP?PRYRPB?BY?Y??B?B...

output:

61578469

result:

ok 1 number(s): "61578469"

Test #27:

score: 0
Accepted
time: 200ms
memory: 35988kb

input:

50000
Y??RPRP?PBYR?BPRPBYB??YBP?PBPB?????B?BYRYBPBYBPRPRYBP?P?YB?B??PBY?PB?R?RPR?RYBY?Y?PBY????B??YBYRPRY??BYR??PRPBP?P?P?Y?YBPRPBYBPRP???Y?P??RPBYBPBY??BY?Y?YRPB??Y?PBYB??P?Y?PRYBY?YBY??R?B??PR???BYRYB?RPBPBPBPR?RP??BYRYB?BP?PRP?P?YBPRP?PBYR???R?RPBP?P?YB?RPR?RYRP??B?RYRYRYBP??B???BYRYRPB??YRPRYBPB...

output:

21239954

result:

ok 1 number(s): "21239954"

Test #28:

score: 0
Accepted
time: 197ms
memory: 36480kb

input:

50000
YR??PB?BP???YRP??BYRPRP?P?PRPRPR?RPRPBYBPBY??B?B?RPRPBYRP??R?B??PR??P?PR?RYBPRPRY????R?R?RY??B?RYB?R?B?BYBPB??YRYRYBY?P?PR?B?RP??RP?YRPRYBPBYB?BYBP????RYRYR?BPRP?YRY?PB???BP??????BPR?RP?YBPB?RY?PBPBP??BYRP?YBYRP?YBYB?RPRYBYBP?YBY?YB?R??PBYBY?PB?R????P??BPRPRPRY???P???PBPRYRYB?RP?YBYRYRY????RP?...

output:

268137953

result:

ok 1 number(s): "268137953"

Test #29:

score: 0
Accepted
time: 200ms
memory: 37140kb

input:

50000
P???PR?RYBPB?RPBYB??YR??PB??YBPBP?Y?P??R?RYBPRPBYB??YB?R????YR?RPRPB?RYB?RPRP???PBYBY?YB?BYR??PR?B???B?R?RPR?RPR??PR?BYBPR????P???P?YRPR??P?PRYRYB?BYBY???P?PB?R??P??RYBPB?R?RYB???B????PRPRYR???BYRYR?B??PBP???PRP?P?YR??YRP??B?BY?Y?PRPRPRYRYRYRPRY?Y??RPBY?YR?BPRPB?R?BYR?BY??BY?P?Y?YBYRYBYRY?P??R...

output:

903429393

result:

ok 1 number(s): "903429393"

Test #30:

score: 0
Accepted
time: 195ms
memory: 36128kb

input:

50000
P??RPBYB?RP?Y??BPBPBPBYRPRPBYRP?YR??P?PBY?Y?????PRYBPBP?Y??BY??BPR?BYB???R?B??YBYRP??BP?YBPRP?YBP?P?Y?PR??YRPBYBPR?BPBY?PRY??RP???PRYBP?YRP?P??R??P?YBPR??P?PRYB?BPRYRYBP??BYB?RP??RPB??PR?R??YBPR?B??YBY?Y???P??BYRP????RYB?RYR?BP?YBP?P???P?PB??PR?RP?PR?R??P?YB?B??P?YRY?Y??RY?P?YBYBYRYRY?YRPBYBYB...

output:

360140728

result:

ok 1 number(s): "360140728"

Test #31:

score: 0
Accepted
time: 191ms
memory: 35392kb

input:

50000
PBYRYRYBYRYBYRPBYRPBPBYBYRYBYBPRPBYRYRYBYRPBPRYBYRYRYRYBYRYRYRPRYBYRPRPRPRYRPBYRPRPBYRPBYRYRPBYRYBPRYRPRYBYBYRYBPRPBYBPRPRPRYRPRYRPRYRPBYBPRPRYRYRPRPRPBYRYRYRPRPBPRPRYRYRYBYRYRYRPBYBYRPBPBYRPRPBPRYBPRPBYBPBPBPBYRYRPRPBYRPBYRYBPRPBYRYBPBPRPRPBYBPRYRPBYBYBYRPRYBYBYBPBYBPBPRYRYRYRPRYBYBYBPBPBYBPR...

output:

0

result:

ok 1 number(s): "0"

Test #32:

score: 0
Accepted
time: 186ms
memory: 35444kb

input:

50000
PRYRPBPRYRYBYRYBYRYRYRPRPBPRPRYBYBPBYRPRYRYRYRYRPBYBPRPRPRPRPRPRYBPRPBYBPBYBYBYRPRPBYBYBYBYBPRPBYBPBPRYRYBYBPBYRYBYRPBYRYRYRYBYBYRYBYRPRPBPBPBPBPBPRPRYBYRYRPBPRPRYBYRPRYRYRYRYRPRPRYRPBPRYRYRPBYBPRPBYRYRYBYRYBPRYBYRYRPRYBYBPRPBYRPBYBYRYRYRYBPBPRPBYBPBYRYBYRPBPBYBPRYBYRYBPBYRYRPBYBPBYBPRPBYBYRYB...

output:

0

result:

ok 1 number(s): "0"

Test #33:

score: 0
Accepted
time: 185ms
memory: 34728kb

input:

50000
PBPRPBYRPRYBYBYRPBPBYRPBPRPBPBPBYRPBYBYRPRYBPRPRYRYBPBPBYRPRYRYRPBYRYRPBPBYRPBPBYRPBYRYBYRYBYBYRYBPRPBYRYRYRPBYRPBYBPRYRYBPRYBYBYRPBPRYRYRYBYRPBPBPBPBPRYBYRPBYBYRYRYBYRYRYBYRPRYRPBYRPBPRYBYRPBPBYRYRPRYRYRYBPBYRPRPRPBPRPRYRPBPBYBPBPBYBYBYBPBYBPRPBYBYRPRPBYBPRPBPRPBYRPBPRYRPRYRYRYBPRPRPRYRPBYBPR...

output:

0

result:

ok 1 number(s): "0"

Test #34:

score: 0
Accepted
time: 222ms
memory: 36932kb

input:

50000
?BY???P????RPB??P???YB?R?BY?YR????PR??P???????P?YRP?PRY?PB??Y?YR???B??Y?YR?BPRYR?B?B?BPRY?Y???PRY?PBYBPRP?Y?PBY?YRP?PR?R??PRYRY?Y?Y?Y?P?PBPB?RP?PRY?P???PRY???P???P???PB?B?B?B?B?BYBP?PR????P??BYRY??????R?B??P?????PBY??R?B??Y?YB??PBPB?B???R?BP??B?BPB?R????YR????YBP?P?YR????Y?PRPB??Y????R?R?RY??B...

output:

908700788

result:

ok 1 number(s): "908700788"

Test #35:

score: 0
Accepted
time: 334ms
memory: 43096kb

input:

50000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

422064317

result:

ok 1 number(s): "422064317"