QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#743733 | #8080. Pa?sWorD | yhddd | ML | 1ms | 3832kb | C++14 | 1.7kb | 2024-11-13 19:53:45 | 2024-11-13 19:53:52 |
Judging History
answer
#include<bits/stdc++.h>
#define mod 998244353ll
#define pii pair<int,int>
#define fi first
#define se second
#define mems(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define db double
using namespace std;
const int maxn=100010;
const int inf=1e18;
inline int read(){
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch-48);ch=getchar();}
return x*f;
}
bool Mbe;
int n,ans;
int dp[maxn][65][8];
char t[maxn];
int id(char c){
if(c>='a'&&c<='z')return c-'a'+1;
if(c>='A'&&c<='Z')return 26+c-'A'+1;
if(c>='0'&&c<='9')return 52+c-'0'+1;
}
void inc(int &u,int v){((u+=v)>=mod)&&(u-=mod);}
void work(){
n=read();scanf("%s",t+1);
dp[0][0][0]=1;
for(int i=1;i<=n;i++){
for(int j=0;j<=62;j++){
for(int s=0;s<8;s++)if(dp[i-1][j][s]){
if(t[i]=='?'){
for(int k=1;k<=26;k++)if(j!=k)inc(dp[i][k][s|1],dp[i-1][j][s]);
for(int k=27;k<=52;k++)if(j!=k)inc(dp[i][k][s|2],dp[i-1][j][s]);
for(int k=53;k<=62;k++)if(j!=k)inc(dp[i][k][s|4],dp[i-1][j][s]);
}
else if(id(t[i])<=26){
int k=id(t[i]);
if(j!=k)inc(dp[i][k][s|1],dp[i-1][j][s]);
k=id(t[i])+26;
if(j!=k)inc(dp[i][k][s|2],dp[i-1][j][s]);
}
else{
int k=id(t[i]);
if(k<=52){
if(j!=k)inc(dp[i][k][s|2],dp[i-1][j][s]);
}
else{
if(j!=k)inc(dp[i][k][s|4],dp[i-1][j][s]);
}
}
}
}
}
for(int i=1;i<=62;i++)inc(ans,dp[n][i][7]);
printf("%lld\n",ans);
}
// \
444
bool Med;
int T;
signed main(){
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
// ios::sync_with_stdio(0);
// cin.tie(0);cout.tie(0);
// cerr<<(&Mbe-&Med)/1048576.0<<" MB\n";
T=1;
while(T--)work();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3832kb
input:
4 a?0B
output:
86
result:
ok single line: '86'
Test #2:
score: -100
Memory Limit Exceeded
input:
100000 1kQOIXnSMDlMqJcA8Ae6ov3DfVWAk0I16BgJ3tW1A6ERqBOy4kYizhqPUAU9DrUK26oQ8tgVQW0sRIcg0J2moqS6rRc5lh6QBtzFNfVDvU?sHilmsDIsywXDEeCy8bFracBGSwWNnkLa49E7d9JNXS1QsWPRoYV6IwSvdLdeYMczFmy7G56rxql6YXsX8AaWRLfxqukM5ovPzuSCTpSpN5?OaCE8xb8xu7xJ4A2pOHTOxe1EStiTlWMLeoM5qW6ULwCK4Dtcru8sjqaTilMzLvU27DcJnUhweXT80...
output:
483479164