QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#569504#8080. Pa?sWorDliubw_#WA 26ms31136kbC++203.3kb2024-09-16 23:49:012024-09-16 23:49:02

Judging History

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

  • [2024-09-16 23:49:02]
  • 评测
  • 测评结果:WA
  • 用时:26ms
  • 内存:31136kb
  • [2024-09-16 23:49: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;
}
bool chk3(){
    for(int i=0;i<n;i++) if('a'<=s[i]&&s[i]<='z') return 0;
    return 1;
}

void print(){
    for(int i=1;i<=n;i++){
        cout<<"i= "<<i<<'\n';
        for(int j=0;j<=62;j++) cout<<"  j="<<j<<" dp="<<dp[i][j]<<'\n';
    }
}

void calc(bool flg1,bool flg2,bool flg3){
    for(int i=1;i<=n;i++){
        if(s[i-1]=='?'){
            if(flg3) for(int j=1;j<=26;j++) dp[i][j]=pls(dp[i-1][0],-dp[i-1][j]);
            if(flg1) for(int j=27;j<=52;j++) dp[i][j]=pls(dp[i-1][0],-dp[i-1][j]);
            if(flg2) for(int j=53;j<=62;j++) dp[i][j]=pls(dp[i-1][0],-dp[i-1][j]);
        }
        if(flg1&&('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(flg2&&('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]);
            if(flg3) dp[i][x]=pls(dp[i-1][0],-dp[i-1][x]);
            x=to_dig(s[i-1]-'a'+'A');
            if(flg1) 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 main(){
    fst_IO();
    cin>>n;
    cin>>s;
    dp[0][0]=1;
    bool flg1=chk1(),flg2=chk2(),flg3=chk3();
    calc(1,1,1);
    int ans=dp[n][0];
    // cerr<<" all condition : "<<dp[n][0]<<'\n';
    // print();
    clear();
    
    calc(1,1,0);
    ans=pls(ans,-dp[n][0]);
    // cerr<<" no lowercase: "<<dp[n][0]<<'\n';
    clear();

    if(flg1){
        calc(0,1,1);
        ans=pls(ans,-dp[n][0]);
        // cerr<<" no uppercase: "<<dp[n][0]<<'\n';
        clear();
    }

    if(flg2){
        calc(1,0,1);
        ans=pls(ans,-dp[n][0]);
        // cerr<<" no digit: "<<dp[n][0]<<'\n';
        clear();
    }

    if(flg2){
        calc(1,0,0);
        ans=pls(ans,dp[n][0]);
        clear();
    }
    if(flg1){
        calc(0,1,0);
        ans=pls(ans,dp[n][0]);
        clear();
    }
    if(flg1&&flg2){
        calc(0,0,1);
        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: 3696kb

input:

4
a?0B

output:

86

result:

ok single line: '86'

Test #2:

score: -100
Wrong Answer
time: 26ms
memory: 31136kb

input:

100000
1kQOIXnSMDlMqJcA8Ae6ov3DfVWAk0I16BgJ3tW1A6ERqBOy4kYizhqPUAU9DrUK26oQ8tgVQW0sRIcg0J2moqS6rRc5lh6QBtzFNfVDvU?sHilmsDIsywXDEeCy8bFracBGSwWNnkLa49E7d9JNXS1QsWPRoYV6IwSvdLdeYMczFmy7G56rxql6YXsX8AaWRLfxqukM5ovPzuSCTpSpN5?OaCE8xb8xu7xJ4A2pOHTOxe1EStiTlWMLeoM5qW6ULwCK4Dtcru8sjqaTilMzLvU27DcJnUhweXT80...

output:

0

result:

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