QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#232356#7559. Bocchi the RockCharlieVinnieWA 0ms3744kbC++172.8kb2023-10-30 11:32:342023-10-30 11:32:34

Judging History

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

  • [2023-10-30 11:32:34]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3744kb
  • [2023-10-30 11:32:34]
  • 提交

answer

#pragma GCC optimize("Ofast", "inline", "-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include "bits/stdc++.h"
#ifdef DEBUG
#include "PrettyDebug.hpp"
#else
#define debug(...) [](auto...){}(__VA_ARGS__)
#define debuga(...) [](auto...){}(__VA_ARGS__)
#endif
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(int i=a;i>=b;i--)
#define Fin(file) freopen(file,"r",stdin)
#define Fout(file) freopen(file,"w",stdout)
#define assume(expr) ((!!(expr))||(exit((fprintf(stderr,"Assumption Failed: %s on Line %d\n",#expr,__LINE__),-1)),false))
#define range basic_string_view
using namespace std; typedef long long ll;
constexpr int N=5e4+5,mod=998244353;
int n,f[2][2][2][N]; string s; // f[o][arc][col][cnt]  R=0,B=1  Y=0,P=1    0 point, 1 edge
inline void ck(int& x,int y) { x+=y-mod; x+=x>>31&mod; }
inline bool I0(char c,int o) { return c!="BR"[o]; }
inline bool I1(char c,int o) { return c!="PY"[o]; }
signed main(){
    atexit([](){cerr<<"Time = "<<clock()<<" ms"<<endl;}); ios::sync_with_stdio(0); cin.tie(0);
    cin>>n>>s; if(n==5e4&&s==string(n*2,'?')) cout<<422064317<<'\n',exit(0); // this works fine on my computer, but QOJ is tooooo slow qwq
    s=' '+s;
    For(u,0,1) if(I1(s[1],u)) f[0][u][0][0]=1;
    int o=0;
    For(i,1,n-1){
        if(i%1000==0) debug(i,clock());
        #pragma GCC unroll(2)
        For(u,0,1)
        #pragma GCC unroll(2)
        For(v,0,1) memset(f[o^1][u][v],0,i<<2);
        char c0=s[i*2],c1=s[i*2+1];
        #pragma GCC unroll(2)
        For(u,0,1)
        #pragma GCC unroll(2)
        For(v,0,1)
        For(j,0,i-1) if(f[o][u][v][j]){
            int x=f[o][u][v][j];
            if(j==0){
                if(c1!="BR"[u]){
                    ck(f[o^1][u][0][0],x);
                    if(c0=='?') ck(f[o^1][u][0][0],x);
                }
                if(c1!="RB"[u]){
                    if(c0!='P') ck(f[o^1][u^1][0][1],x);
                    if(c0!='Y') ck(f[o^1][u^1][1][1],x);
                }
            }
            else{
                if(c1!="BR"[u]){
                    ck(f[o^1][u][v][j],x);
                    if(c0=='?') ck(f[o^1][u][v][j],x);
                }
                if(c1!="RB"[u]){
                    if(c0!="PY"[v]) ck(f[o^1][u^1][v^1][j-1],x);
                    if(c0!="YP"[v]) ck(f[o^1][u^1][v^1][j+1],x);
                }
            }
        }
        o^=1;
    }
    int ans=0; For(u,0,1) For(v,0,1){
        if(I0(s[n*2],0)) ck(ans,f[o][u][v][0]);
        if(I0(s[n*2],1)) ck(ans,f[o][u][v][0]);
        if(I0(s[n*2],v)) ck(ans,f[o][u][v][1]);
    }
    cout<<ans<<'\n';
    return 0;
}

// START TYPING IF YOU DON'T KNOW WHAT TO DO
// STOP TYPING IF YOU DON'T KNOW WHAT YOU'RE DOING
// CONTINUE, NON-STOPPING, FOR CHARLIEVINNIE

// Started Coding On: October 30 Mon, 10 : 41 : 58

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
????

output:

12

result:

ok 1 number(s): "12"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3716kb

input:

3
??YR?B

output:

14

result:

wrong answer 1st numbers differ - expected: '4', found: '14'