QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#569479#8080. Pa?sWorDliubw_#WA 15ms31064kbC++204.0kb2024-09-16 23:30:012024-09-16 23:30:02

Judging History

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

  • [2024-09-16 23:30:02]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:31064kb
  • [2024-09-16 23:30:01]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define max(A,B) (A>B? A:B)
#define min(A,B) (A<B? A:B)
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define pir(X) pair<X,X>
#define mpr(A,B) make_pair(A,B)
#define fr first
#define sc second
using namespace std;

const int N=1e5+10;

const int mod=998244353;
int pls(int a,int b){
    if(a+b>=mod) return a+b-mod;
    if(a+b<0) return a+b+mod;
    return a+b;
}
int mul(int a,int b){
    return (ll)a*b%mod;
}
int qpow(int a,int b){
    int ret=1;
    while(b){
        if(b&1) ret=mul(ret,a);
        a=mul(a,a);
        b>>=1;
    }
    return ret;
}

int n,dp[N][70];
string s;
int to_dig(char c){
    if('a'<=c&&c<='z') return c-'a'+1;
    if('A'<=c&&c<='Z') return c-'A'+1+26;
    if('0'<=c&&c<='9') return c-'0'+1+52;
}


void fst_IO(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
void clear(){
    for(int i=1;i<=n;i++){
        for(int j=0;j<=62;j++) dp[i][j]=0;
    }
}

bool chk1(){
    for(int i=0;i<n;i++) if('A'<=s[i]&&s[i]<='Z') return 0;
    return 1;
}
bool chk2(){
    for(int i=0;i<n;i++) if('0'<=s[i]&&s[i]<='9') return 0;
    return 1;
}

int main(){
    fst_IO();
    cin>>n;
    cin>>s;
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        if(s[i-1]=='?'){
            for(int j=1;j<=62;j++) dp[i][j]=pls(dp[i-1][0],-dp[i-1][j]);
        }
        if(('0'<=s[i-1]&&s[i-1]<='0')||('A'<=s[i-1]&&s[i-1]<='Z')) dp[i][to_dig(s[i-1])]=pls(dp[i-1][0],-dp[i-1][to_dig(s[i-1])]);
        if('a'<=s[i-1]&&s[i-1]<='z'){
            int x=to_dig(s[i-1]);
            dp[i][x]=pls(dp[i-1][0],-dp[i-1][x]);
            x=to_dig(s[i-1]-'a'+'A');
            dp[i][x]=pls(dp[i-1][0],-dp[i-1][x]);
        }
        for(int j=1;j<=62;j++) dp[i][0]=pls(dp[i][0],dp[i][j]);
    }

    int ans=dp[n][0];
    clear();
    for(int i=1;i<=n;i++){
        if(s[i-1]=='?'){
            for(int j=27;j<=62;j++) dp[i][j]=pls(dp[i-1][0],-dp[i-1][j]);
        }
        if(('0'<=s[i-1]&&s[i-1]<='0')||('A'<=s[i-1]&&s[i-1]<='Z')) dp[i][to_dig(s[i-1])]=pls(dp[i-1][0],-dp[i-1][to_dig(s[i-1])]);
        if('a'<=s[i-1]&&s[i-1]<='z'){
            // int x=to_dig(s[i-1]);
            // dp[i][x]=pls(dp[i-1][0],-dp[i-1][x]);
            int x=to_dig(s[i-1]-'a'+'A');
            dp[i][x]=pls(dp[i-1][0],-dp[i-1][x]);
        }
        for(int j=1;j<=62;j++) dp[i][0]=pls(dp[i][0],dp[i][j]);
    }

    ans=pls(ans,-dp[n][0]);
    clear();
    if(chk1()){
        for(int i=1;i<=n;i++){
            if(s[i-1]=='?'){
                for(int j=1;j<=26;j++) dp[i][j]=pls(dp[i-1][0],-dp[i-1][j]);
                for(int j=53;j<=62;j++) dp[i][j]=pls(dp[i-1][0],-dp[i-1][j]);
            }
            if(('0'<=s[i-1]&&s[i-1]<='0')) dp[i][to_dig(s[i-1])]=pls(dp[i-1][0],-dp[i-1][to_dig(s[i-1])]);
            if('a'<=s[i-1]&&s[i-1]<='z'){
                int x=to_dig(s[i-1]);
                dp[i][x]=pls(dp[i-1][0],-dp[i-1][x]);
                // x=to_dig(s[i-1]-'a'+'A');
                // dp[i][x]=pls(dp[i-1][0],-dp[i-1][x]);
            }
            for(int j=1;j<=62;j++) dp[i][0]=pls(dp[i][0],dp[i][j]);
        }
        ans=pls(ans,-dp[n][0]);
        clear();
    }

    if(chk2()){
        for(int i=1;i<=n;i++){
            if(s[i-1]=='?'){
                for(int j=1;j<=52;j++) dp[i][j]=pls(dp[i-1][0],-dp[i-1][j]);
            }
            if(('A'<=s[i-1]&&s[i-1]<='Z')) dp[i][to_dig(s[i-1])]=pls(dp[i-1][0],-dp[i-1][to_dig(s[i-1])]);
            if('a'<=s[i-1]&&s[i-1]<='z'){
                int x=to_dig(s[i-1]);
                dp[i][x]=pls(dp[i-1][0],-dp[i-1][x]);
                x=to_dig(s[i-1]-'a'+'A');
                dp[i][x]=pls(dp[i-1][0],-dp[i-1][x]);
            }
            for(int j=1;j<=52;j++) dp[i][0]=pls(dp[i][0],dp[i][j]);
        }
        ans=pls(ans,-dp[n][0]);
        clear();
    }

    cout<<ans<<'\n';
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
a?0B

output:

86

result:

ok single line: '86'

Test #2:

score: -100
Wrong Answer
time: 15ms
memory: 31064kb

input:

100000
1kQOIXnSMDlMqJcA8Ae6ov3DfVWAk0I16BgJ3tW1A6ERqBOy4kYizhqPUAU9DrUK26oQ8tgVQW0sRIcg0J2moqS6rRc5lh6QBtzFNfVDvU?sHilmsDIsywXDEeCy8bFracBGSwWNnkLa49E7d9JNXS1QsWPRoYV6IwSvdLdeYMczFmy7G56rxql6YXsX8AaWRLfxqukM5ovPzuSCTpSpN5?OaCE8xb8xu7xJ4A2pOHTOxe1EStiTlWMLeoM5qW6ULwCK4Dtcru8sjqaTilMzLvU27DcJnUhweXT80...

output:

0

result:

wrong answer 1st lines differ - expected: '483479164', found: '0'