QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#783614#8080. Pa?sWorDfsdhmbb#RE 0ms3556kbC++174.2kb2024-11-26 11:00:542024-11-26 11:00:55

Judging History

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

  • [2024-11-26 11:00:55]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3556kb
  • [2024-11-26 11:00:54]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
const int mod=998244353;
int n;
string s;
int f[2][65][8];
int remap(char ch)
{
    if(ch>='0'&&ch<='9') return ch-'0';
    else if(ch>='A'&&ch<='Z') return ch-'A'+10;
    else return ch-'a'+36;
}
int remap2(char ch)
{
    if(remap(ch)<10) return 0;
    else if(remap(ch)<36) return 1;
    else return 2;
}
int remap3(int x)
{
    if(x<10) return 0;
    else if(x<36) return 1;
    else return 2;
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    cin>>s;
    int now=0;
    if(s[0]=='?')
    {
        for(int i=0;i<62;i++)
        {
            if(1!=s.size()&&s[1]!='?'&&remap(s[i+1])==i) continue;
            f[now][i][1<<(remap3(i))]=1;
        }
    }
    else if(s[0]<36) f[now][remap(s[0])][1<<remap2(s[0])]=1;
    else 
    {
        if(s.size()==1||s[1]=='?'||remap(s[1])!=remap(s[0])) f[now][remap(s[0])][1<<remap2(s[0])]=1;
        if(s.size()==1||s[1]=='?'||remap(s[1])!=remap(s[0])-26) f[now][remap(s[0])-26][1<<remap3(remap(s[0])-26)]=1;
    }
    for(int i=1;i<(int)s.size();i++)
    {
        now=now^1;
        for(int j=0;j<62;j++) for(int k=0;k<8;k++) f[now][j][k]=0;
        if(s[i]=='?')
        {
            int sum[8]={0};
            for(int j=0;j<62;j++)
            {
                for(int k=0;k<8;k++)
                {
                    sum[k]=(sum[k]+f[now^1][j][k])%mod;
                }
            }
            // for(int j=0;j<62;j++)
            // {
            //     if(i!=s.size()-1&&s[i+1]!='?'&&remap(s[i+1])==j) continue;
            //     int sum2=0;
            //     for(int k=0;k<8;k++) sum2=(sum-f[now^1][j][k]+mod)%mod;
            //     for(int k=0;k<8;k++)
            //     {
            //         if(!((1<<remap3(j))&k)) continue;
            //         f[now][j][k]=(f[now][j][k]+sum2)%mod;
            //     }
            // }
            for(int j=0;j<62;j++)
            {
                if(i!=(int)s.size()-1&&s[i+1]!='?'&&remap(s[i+1])==j) continue;
                // cout<<j<<" ";
                int sum2[8]={0};
                for(int k=0;k<8;k++) sum2[k]=(sum[k]-f[now^1][j][k]+mod)%mod;
                for(int k=0;k<8;k++)
                {
                    if(!((1<<remap3(j))&k)) continue;
                    f[now][j][k]=(f[now][j][k]+(sum2[k]+sum2[(1<<(remap3(j)))^k]))%mod;
                }
            }
        }
        else if(remap(s[i])<36)
        {
            for(int j=0;j<62;j++)
            {
                for(int k=0;k<8;k++)
                {
                    f[now][remap(s[i])][k|(1<<remap2(s[i]))]+=f[now^1][j][k];
                    f[now][remap(s[i])][k|(1<<remap2(s[i]))]%=mod;
                }
            }
        }
        else
        {
            if(i==(int)s.size()-1||s[i+1]=='?'||remap(s[i+1])!=remap(s[i]))
            {
                for(int j=0;j<62;j++)
                {
                    for(int k=0;k<8;k++)
                    {
                        f[now][remap(s[i])][k|(1<<remap2(s[i]))]+=f[now^1][j][k];
                        f[now][remap(s[i])][k|(1<<remap2(s[i]))]%=mod;
                    }
                }
            }
            if(i==(int)s.size()-1||s[i+1]=='?'||remap(s[i+1])!=remap(s[i])-26)
            {
                for(int j=0;j<62;j++)
                {
                    for(int k=0;k<8;k++)
                    {
                        f[now][remap(s[i])-26][k|(1<<remap3(remap(s[i])-26))]+=f[now^1][j][k];
                        f[now][remap(s[i])-26][k|(1<<remap3(remap(s[i])-26))]%=mod;
                    }
                }
            }
        }
        // if(i==3)
        // {
        //     for(int j=0;j<62;j++)
        //     {
        //         cout<<j<<" ";
        //         for(int k=0;k<8;k++) cout<<f[now][j][k]<<" ";
        //         cout<<endl;
        //     }
        // }
    }
    // for(int j=0;j<62;j++)
    // {
    //     cout<<j<<" ";
    //     for(int k=0;k<8;k++) cout<<f[now][j][k]<<" ";
    //     cout<<endl;
    // }
    int ans=0;
    for(int i=0;i<62;i++) ans=(ans+f[now][i][7])%mod;
    cout<<ans<<endl;
    return 0;
}

詳細信息

Test #1:

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

input:

4
a?0B

output:

86

result:

ok single line: '86'

Test #2:

score: -100
Runtime Error

input:

100000
1kQOIXnSMDlMqJcA8Ae6ov3DfVWAk0I16BgJ3tW1A6ERqBOy4kYizhqPUAU9DrUK26oQ8tgVQW0sRIcg0J2moqS6rRc5lh6QBtzFNfVDvU?sHilmsDIsywXDEeCy8bFracBGSwWNnkLa49E7d9JNXS1QsWPRoYV6IwSvdLdeYMczFmy7G56rxql6YXsX8AaWRLfxqukM5ovPzuSCTpSpN5?OaCE8xb8xu7xJ4A2pOHTOxe1EStiTlWMLeoM5qW6ULwCK4Dtcru8sjqaTilMzLvU27DcJnUhweXT80...

output:


result: