QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#545659 | #7559. Bocchi the Rock | hank55663 | AC ✓ | 8908ms | 202512kb | C++17 | 9.7kb | 2024-09-03 15:59:12 | 2024-09-03 15:59:12 |
Judging History
answer
#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
#define pdd pair<double,double>
#define pii pair<int,int>
#define pll pair<LL,LL>
#define mp make_pair
#define LL long long
#define ULL unsigned long long
#define sqr(x) ((x)*(x))
#define pi acos(-1)
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
using namespace std;
const int mod=998244353;
const int P=998244353,root=3,MAXNUM=1<<23;
// Remember coefficient are mod P
/*
p=a*2^n+1 degree(poly) <= 2^n
n 2^n p a root
16 65536 65537 1 3
20 1048576 7340033 7 3
23 998244353 119 3
*/
int bigmod(long long a,int b){
if(b==0)return 1;
return (bigmod((a*a)%P,b/2)*(b%2?a:1ll))%P;
}
int inv(int a,int b){
if(a==1)return 1;
return (((long long)(a-inv(b%a,a))*b+1)/a)%b;
}
std::vector<long long> ps(MAXNUM);
std::vector<int> rev(MAXNUM);
LL f_pow(unsigned int a,LL b){
LL res=1,temp=a;
while(b){
if(b&1)res=res*temp%P;
temp=temp*temp%P;
b>>=1;
}
return res;
}
struct poly{
std::vector<unsigned int> co;
int n;//polynomial degree = n
poly(){n=0;co.clear();}
poly(int d){n=d;co.resize(n+1,0);}
void ntt(int NN){
int r=0,st,N;
unsigned int a,b;
//while((1<<r)<(NN>>1))++r;//inv:r=0
//for(N=2;N<=NN;N<<=1,--r){
for(N=NN;N>1;N>>=1,r++){
for(st=0;st<NN;st+=N){
int i,ss=st+(N>>1);
for(i=(N>>1)-1;i>=0;--i){
a=co[st+i];// b=(ps[i<<r]*co[ss+i])%P;
b=co[ss+i];
co[st+i]=a+b; if(co[st+i]>=P)co[st+i]-=P;
///co[ss+i]=a+P-b; if(co[ss+i]>=P)co[ss+i]-=P;
co[ss+i]=((a+P-b)*ps[i<<r])%P;
}
}
}
}
void ntt_inv(int NN){
int r=0,st,N;
unsigned int a,b;
while((1<<r)<(NN>>1))++r;//inv:r=0
for(N=2;N<=NN;N<<=1,--r){
//inv for(N=NN;N>1;N>>=1,r++){
for(st=0;st<NN;st+=N){
int i,ss=st+(N>>1);
for(i=(N>>1)-1;i>=0;--i){
a=co[st+i]; b=(ps[i<<r]*co[ss+i])%P;
//inv b=co[ss+i];
co[st+i]=a+b; if(co[st+i]>=P)co[st+i]-=P;
co[ss+i]=a+P-b; if(co[ss+i]>=P)co[ss+i]-=P;
//inv co[ss+i]=((a+P-b)*ps[i<<r])%P;
}
}
}
}
poly operator*(const poly& _b)const{
poly a=*this,b=_b;
int k=n+b.n,i,N=1;
while(N<=k)N*=2;
a.co.resize(N,0); b.co.resize(N,0);
int r=bigmod(root,(P-1)/N),Ni=inv(N,P);
ps[0]=1;
for(i=1;i<N;++i)ps[i]=(ps[i-1]*r)%P;
a.ntt(N);b.ntt(N);
for(i=0;i<N;++i)a.co[i]=((long long)a.co[i]*b.co[i])%P;
r=inv(r,P);
for(i=1;i<N/2;++i)std::swap(ps[i],ps[N-i]);
a.ntt_inv(N);
for(i=0;i<N;++i)a.co[i]=((long long)a.co[i]*Ni)%P;
a.n=n+_b.n; return a;
}
};
char c[2000005];
vector<pair<poly,int> > dc(int l,int r){
if(r-l<=1000){
int dp[2][2][2005],dp2[2][2][2005];
MEM(dp);
MEM(dp2);
if(c[l*2]!='Y')dp[0][0][1000]++;
if(c[l*2]!='P')dp[1][1][1000]++;
for(int i = l*2+2;i<=r*2;i+=2){
if(c[i]!='Y'){
for(int j = 0;j<2;j++){
for(int k = 0;k<2;k++){
if(k==0){
for(int a=0;a<=2000;a++){
if(c[i-1]=='?')
dp2[j][0][a]+=dp[j][k][a]*2%mod;
else dp2[j][0][a]+=dp[j][k][a];
dp2[j][0][a]%=mod;
}
}
else{
if(c[i-1]!='R')
for(int a=0;a<=2000;a++){
dp2[j][0][a]+=dp[j][k][a];
dp2[j][0][a]%=mod;
}
if(c[i-1]!='B'){
for(int a=1;a<=2000;a++){
dp2[j][0][a-1]+=dp[j][k][a];
dp2[j][0][a-1]%=mod;
}
}
}
}
}
}
if(c[i]!='P'){
for(int j = 0;j<2;j++){
for(int k = 0;k<2;k++){
if(k==1){
for(int a=0;a<=2000;a++){
if(c[i-1]=='?')
dp2[j][1][a]+=dp[j][k][a]*2%mod;
else dp2[j][1][a]+=dp[j][k][a];
dp2[j][1][a]%=mod;
}
}
else{
if(c[i-1]!='R')
for(int a=0;a<=2000;a++){
dp2[j][1][a]+=dp[j][k][a];
dp2[j][1][a]%=mod;
}
if(c[i-1]!='B'){
for(int a=0;a<=1999;a++){
dp2[j][1][a+1]+=dp[j][k][a];
dp2[j][1][a+1]%=mod;
}
}
}
}
}
}
for(int a=0;a<2;a++){
for(int b=0;b<2;b++){
for(int c=0;c<=2000;c++){
dp[a][b][c]=dp2[a][b][c];
dp2[a][b][c]=0;
// if(dp[a][b][c])
// printf("%d %d %d %d %d\n",i,a,b,c-100,dp[a][b][c]);
}
}
}
}
vector<pair<poly,int> > v;
for(int a=0;a<2;a++){
for(int b=0;b<2;b++){
int st=-1;
poly p(0);
p.co.clear();
for(int c=0;c<=2000;c++){
if(dp[a][b][c]&&st==-1){
st=c;
}
if(st!=-1)p.co.push_back(dp[a][b][c]);
}
while(p.co.size()&&p.co.back()==0)p.co.pop_back();
if(p.co.empty())p.co.pb(0),st=1000;
p.n=p.co.size()-1;
v.pb(mp(p,st-1000));
}
}
return v;
}
else{
int mid=(l+r)/2;
auto v1=dc(l,mid);
auto v2=dc(mid+1,r);
vector<pair<poly,int> > v(4);
for(int i = 0;i<4;i++){
for(int j = 0;j<4;j++){
int x1=i>>1,x2=i&1;
int y1=j>>1,y2=j&1;
poly p=v1[i].x*v2[j].x;
LL a1=0,a2=0,a3=0;
int d=v1[i].y+v2[j].y;
int q=x1*2+y2;
reverse(v[q].x.co.begin(),v[q].x.co.end());
while(d<v[q].y){
v[q].y--;
v[q].x.co.pb(0);
v[q].x.n++;
}
reverse(v[q].x.co.begin(),v[q].x.co.end());
LL a4=0;
if(c[mid*2+1]!='R')
for(int i = 0;i<p.co.size();i++){
while(v[q].x.co.size()<=i+d-v[q].y)v[q].x.co.pb(0),v[q].x.n++;
v[q].x.co[i+d-v[q].y]+=p.co[i];
v[q].x.co[i+d-v[q].y]%=mod;
}
if(c[mid*2+1]!='B'){
if(x2==0&&y1==1)d++;
if(x2==1&&y1==0)d--;
reverse(v[q].x.co.begin(),v[q].x.co.end());
while(d<v[q].y){
v[q].y--;
v[q].x.co.pb(0);
v[q].x.n++;
}
reverse(v[q].x.co.begin(),v[q].x.co.end());
for(int i = 0;i<p.co.size();i++){
while(v[q].x.co.size()<=i+d-v[q].y)v[q].x.co.pb(0),v[q].x.n++;
v[q].x.co[i+d-v[q].y]+=p.co[i];
v[q].x.co[i+d-v[q].y]%=mod;
}
}
// printf("%d %d\n",v[q].x.n,p.n);
}
}
/* printf("ans: %d %d\n ",l,r);
for(int i = 0;i<4;i++){
printf("%d\n",v[i].y);
for(auto it:v[i].x.co)printf("%d ",it);
printf("\n");
}*/
return v;
}
}
void solve(int T){
int n;
scanf("%d",&n);
scanf("%s",c);
// for(int i = 0;i<2*n;i++)c[i]='?';
auto p=dc(0,n-1);
LL ans=0;
for(int i = 0;i<2;i++){
for(int j = 0;j<2;j++){
int q=i*2+j;
if(i==j){
if(c[2*n-1]!='R'){
int need=-p[q].y;
if(p[q].x.co.size()>need&&need>=0)ans+=p[q].x.co[need];
}
if(c[2*n-1]!='B'){
int need=-p[q].y;
if(p[q].x.co.size()>need&&need>=0)ans+=p[q].x.co[need];
}
}
else{
if(c[2*n-1]!='R'){
int need=-p[q].y;
if(p[q].x.co.size()>need&&need>=0)ans+=p[q].x.co[need];
}
if(c[2*n-1]!='B'){
int need=-p[q].y;
if(j==0&&i==1)need--;
if(j==1&&i==0)need++;
if(p[q].x.co.size()>need&&need>=0)ans+=p[q].x.co[need];
}
}
}
}
printf("%lld\n",ans%mod);
}
int main(){
int t=1;0000;
for(int i = 1;i<=t;i++){
solve(i);
}
return 0;
}
/*
1543904 3707852 107840
1 23
JAY'S SON JA$ON
3 4
1 2 1 3
1 3 1 5
1 2 2 2
1 3 3 5
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 101700kb
input:
2 ????
output:
12
result:
ok 1 number(s): "12"
Test #2:
score: 0
Accepted
time: 11ms
memory: 101644kb
input:
3 ??YR?B
output:
4
result:
ok 1 number(s): "4"
Test #3:
score: 0
Accepted
time: 0ms
memory: 101268kb
input:
5 YBYRPBYRYB
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: 0
Accepted
time: 6ms
memory: 101660kb
input:
10 PRPBPRPRPRPBYB?R?BY?
output:
3
result:
ok 1 number(s): "3"
Test #5:
score: 0
Accepted
time: 3ms
memory: 101576kb
input:
10 ?R?R?BYB?R?R?B?B?BYR
output:
96
result:
ok 1 number(s): "96"
Test #6:
score: 0
Accepted
time: 7ms
memory: 101600kb
input:
10 YRPRYRY???P?YB?BYRY?
output:
32
result:
ok 1 number(s): "32"
Test #7:
score: 0
Accepted
time: 0ms
memory: 101740kb
input:
10 PBYBPRPBYRPBYRYBPRPB
output:
0
result:
ok 1 number(s): "0"
Test #8:
score: 0
Accepted
time: 3ms
memory: 101140kb
input:
10 PBPRPRYBYRYRYB?B?RYB
output:
0
result:
ok 1 number(s): "0"
Test #9:
score: 0
Accepted
time: 11ms
memory: 101700kb
input:
10 PRP?PBPRYR??Y?YRPB?R
output:
12
result:
ok 1 number(s): "12"
Test #10:
score: 0
Accepted
time: 3ms
memory: 101704kb
input:
10 ?RYB??P??B?B?B???RPR
output:
416
result:
ok 1 number(s): "416"
Test #11:
score: 0
Accepted
time: 711ms
memory: 102432kb
input:
50000 YBPBYRPRPRPRPBPRPBPBPBYRPRPBPBYRPBPRYBYBPBPBPRPBPBYRYBYRPBYRYRPBYRYRYRPBYBYRPBPBYBYBPBYRPBPBYBYBYRPBPRYBPBYBPRPRYBPRPBYBPRPBYRPBYBPRYBPBPBYRYBYBYBPRYBYRPRPRPRPRYRYBPBPBPBPRPRYBYRYBPRPRPRPBYBPBPRYRPRPBYRPBYRYRPBYBYBPBYRYRPBPRYBPRYBPBPBYRPBPBYBYBPRPBYBYBYRYRPBPRPRPRPRPRYBPBPBPRYBYRPRPRYBYRPRPBYR...
output:
0
result:
ok 1 number(s): "0"
Test #12:
score: 0
Accepted
time: 710ms
memory: 102464kb
input:
50000 YRPBPBYRYRYRYBYBYRPBPBPBPBPBYRYBPBPRYBPBYRYRPRYBYBYBYRPRPBPBPRYRPBYBYBPBYRYRPRPBPBPBPRYBYBYRYRPRPRYBPRPBYRPBPRYRPRYBPRYBYBYRYRYBYRYRYBYRPBPBPBYBPBPRPBPRYRPRYBYBPBPRPBPBPRPRPBYRYRPBPBPBYRPBYBYBYRPBPRPBPRYBPRPRYBPRPBPBYRYRYRYBYRPRPRYBYBYBPBPRPBPRYRYRPRPRPBPBPRPRPBYBYRPRPRPBYBYRPBYBPRPRPRPRPRPBPB...
output:
0
result:
ok 1 number(s): "0"
Test #13:
score: 0
Accepted
time: 706ms
memory: 102552kb
input:
50000 PRPRYBPBYBYBPBYRPBYRYBPBPBPRPRPBYBYRPRPRPRPRPRYRYBYRPBPBPRYRPRPBPRPBPRPRPRPBYRYRYRPBYBYRYRPRPRPRPRYBYBYBYBPBPRPBPBPRYRPRYRPRPRYRPRPBPBYRYBPRPRYRPBPBYBYBPBYRPBPRYRPRYRYBPBPBPRPBPRPRPRYBPBPBYBYBPRYRPRYRPBYRYBYRYRPBYBPBPRPRYRPRYBYRPRPRYBYBYBPBYRYRYRYRYRYRPBYBYRYRYBYRPRYRPBPBYBYRYBPBYBPRYBPBYRYBPR...
output:
0
result:
ok 1 number(s): "0"
Test #14:
score: 0
Accepted
time: 711ms
memory: 102556kb
input:
50000 YRPRPBPRYRYRPRYBPBYRPRPBYRYRYRPBPBYRPRYBYBYBPRYRPBPRPBPBYRPRPRPBPBYBYBPRPRPRYRYRYBYRPBYBPBPRYBPRYBYBYBPBYBYBPBPBPRYRPRPBYRYBYRPRYBYRPRYRPRPRYRPBYRYRYBYRYRPRYRYRPBPRPBYRYRPBYRPBPBPBPRPBYBYBPRYBPBPBYRYRYBYRPRPBPRYBPRPBYRPBYBYBPBPRPBYRYRPRPBPRPBPBYRPRPBYRPRPRYRYRPBYBYBPBPBYBPBYBYRYBYRPBPBPBPRYRPB...
output:
0
result:
ok 1 number(s): "0"
Test #15:
score: 0
Accepted
time: 702ms
memory: 102456kb
input:
50000 YBPBYRPRYRPRPBPBYBYRPBYRPBPRPRPBPBPBYRYBYRPBYRYRPBYRPRPRYBPRYRYBYBPRPRYBYBPRPRPRYRPRYBPRPBYRPBYRPBYRPRPBPBPRPBPBYRYBPRPBPBPBPBYRYRPRPRYBYRPRYBYBYBYBYRYRPBPRYRYRPRYBPRPBPRPRPRPRPBPRPBYBPBPBPBYRPBYBPBPRPBYRPRPRYRYBYRPRPBPRYBYRPBPRPBPRYRPRYBYRYBYBPRPRPRPBYRPBPBYRYRPBPRYBPRYBPRYBPRYBYRPBYBPBPBYRPR...
output:
0
result:
ok 1 number(s): "0"
Test #16:
score: 0
Accepted
time: 118ms
memory: 102288kb
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: 102ms
memory: 102168kb
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: 117ms
memory: 102112kb
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: 108ms
memory: 102224kb
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: 105ms
memory: 102412kb
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: 69ms
memory: 101824kb
input:
5000 PRPBPRPRYRPRPBYBPBPBYRPBPBPBYRYRYBPBYRPRYBPBPRYBPBYRPRYBYRYRPBPBPBPBYRPBYRYBYRPRYBPBPBPRYBPRYBYBPRPBPBYRYBPRPBYRYRPRYBPRPRPBYRPBYRYRPRPRYRYRYBYBPBPBPBPRPRPBPRPRYRPBYRYRYRPBPRPRYRPRPBYBYBPBPRPRYRPBPRYBPRYBPRPRYRPRYRPBPRYBPRPRYBYRPBYRPRYBPRPRYBYRPRYRYBPRYBPRPBPRPRPRYBYRYRYRYRPBPRPBPRPBPRPBPRYRYBY...
output:
0
result:
ok 1 number(s): "0"
Test #22:
score: 0
Accepted
time: 83ms
memory: 101700kb
input:
5000 PRYRYBPBPRYRYRYRPBPBYBYRPBPBYRPRPRYBYRPRYRPBPRYBPBYRPRYRYRYBPBPBYBPBYBPBYRYRYRYRYBYRPRPBYRYBPRYBYBPRPRPBYRYRYRPBYBPBPRPRYRPRPBPRYBYBPBPBYBPBPBPRPBYRYRYRYRPRYBYBPBYBYBPBYBYRPRYRPRPRYBYRYBYRYRYBYBYRPBPRYRYRPRPRPRPRYRPRYRYRPBYBYRPBYBPBPRYBPBYBPBPRYRYRPBPRPRPBPRYRPRYBPBYRPRYBPBYRYBPRPRYRYBYBPRPBYBP...
output:
0
result:
ok 1 number(s): "0"
Test #23:
score: 0
Accepted
time: 71ms
memory: 101916kb
input:
5000 PBYRYRYBYBPBYBYBPBYBYRPRYBYRPRPBYRYBPRYBPRPRYRYRPBYRYRPRYRYBPBYBPBPRPBPRPBPBP?YRPBYBYBPRPRPBPRYRPRYBPRYRYBYRPRYBYBPBYRPBPBYBYRYBPRPBYRYBPBYBYRYRYRPRPRYBYBPRYRPRYBYBYBPRYBPBYRYBPBPRPRPBYBYRYBYRPRYBYBYBYBYBPBYRPRPRPRPRYBYRPRYRYRYBYRPBYRPBPRPRYBPBYBYRPRYBPRYBPRPRPRPBYRPRPBYRYBY?PRYRYRYBPRYRYBYRYBY...
output:
172032
result:
ok 1 number(s): "172032"
Test #24:
score: 0
Accepted
time: 136ms
memory: 102676kb
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: 250ms
memory: 103192kb
input:
5000 ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...
output:
312356960
result:
ok 1 number(s): "312356960"
Test #26:
score: 0
Accepted
time: 2483ms
memory: 125468kb
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: 2367ms
memory: 125088kb
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: 2408ms
memory: 124628kb
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: 2404ms
memory: 124780kb
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: 2401ms
memory: 124552kb
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: 718ms
memory: 102668kb
input:
50000 PBYRYRYBYRYBYRPBYRPBPBYBYRYBYBPRPBYRYRYBYRPBPRYBYRYRYRYBYRYRYRPRYBYRPRPRPRYRPBYRPRPBYRPBYRYRPBYRYBPRYRPRYBYBYRYBPRPBYBPRPRPRYRPRYRPRYRPBYBPRPRYRYRPRPRPBYRYRYRPRPBPRPRYRYRYBYRYRYRPBYBYRPBPBYRPRPBPRYBPRPBYBPBPBPBYRYRPRPBYRPBYRYBPRPBYRYBPBPRPRPBYBPRYRPBYBYBYRPRYBYBYBPBYBPBPRYRYRYRPRYBYBYBPBPBYBPR...
output:
0
result:
ok 1 number(s): "0"
Test #32:
score: 0
Accepted
time: 711ms
memory: 102776kb
input:
50000 PRYRPBPRYRYBYRYBYRYRYRPRPBPRPRYBYBPBYRPRYRYRYRYRPBYBPRPRPRPRPRPRYBPRPBYBPBYBYBYRPRPBYBYBYBYBPRPBYBPBPRYRYBYBPBYRYBYRPBYRYRYRYBYBYRYBYRPRPBPBPBPBPBPRPRYBYRYRPBPRPRYBYRPRYRYRYRYRPRPRYRPBPRYRYRPBYBPRPBYRYRYBYRYBPRYBYRYRPRYBYBPRPBYRPBYBYRYRYRYBPBPRPBYBPBYRYBYRPBPBYBPRYBYRYBPBYRYRPBYBPBYBPRPBYBYRYB...
output:
0
result:
ok 1 number(s): "0"
Test #33:
score: 0
Accepted
time: 708ms
memory: 102656kb
input:
50000 PBPRPBYRPRYBYBYRPBPBYRPBPRPBPBPBYRPBYBYRPRYBPRPRYRYBPBPBYRPRYRYRPBYRYRPBPBYRPBPBYRPBYRYBYRYBYBYRYBPRPBYRYRYRPBYRPBYBPRYRYBPRYBYBYRPBPRYRYRYBYRPBPBPBPBPRYBYRPBYBYRYRYBYRYRYBYRPRYRPBYRPBPRYBYRPBPBYRYRPRYRYRYBPBYRPRPRPBPRPRYRPBPBYBPBPBYBYBYBPBYBPRPBYBYRPRPBYBPRPBPRPBYRPBPRYRPRYRYRYBPRPRPRYRPBYBPR...
output:
0
result:
ok 1 number(s): "0"
Test #34:
score: 0
Accepted
time: 3167ms
memory: 138912kb
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: 8908ms
memory: 202512kb
input:
50000 ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...
output:
422064317
result:
ok 1 number(s): "422064317"