QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#743771 | #8080. Pa?sWorD | yhddd | WA | 30ms | 4048kb | C++14 | 2.0kb | 2024-11-13 19:59:14 | 2024-11-13 19:59:18 |
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[2][65][8],cur;
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++){
mems(dp[i&1],0);
if(t[i]=='?'){
for(int s=0;s<8;s++){
int ss=0;
for(int j=0;j<=52;j++)inc(ss,dp[cur][j][s]);
for(int k=1;k<=26;k++)inc(dp[i&1][k][s|1],ss),inc(dp[i&1][k][s|1],mod-dp[cur][k][s]);
for(int k=27;k<=52;k++)inc(dp[i&1][k][s|2],ss),inc(dp[i&1][k][s|2],mod-dp[cur][k][s]);
for(int k=53;k<=62;k++)inc(dp[i&1][k][s|4],ss),inc(dp[i&1][k][s|4],mod-dp[cur][k][s]);
}
}
else{
for(int j=0;j<=62;j++){
for(int s=0;s<8;s++)if(dp[cur][j][s]){
if(id(t[i])<=26){
int k=id(t[i]);
if(j!=k)inc(dp[i&1][k][s|1],dp[cur][j][s]);
k=id(t[i])+26;
if(j!=k)inc(dp[i&1][k][s|2],dp[cur][j][s]);
}
else{
int k=id(t[i]);
if(k<=52){
if(j!=k)inc(dp[i&1][k][s|2],dp[cur][j][s]);
}
else{
if(j!=k)inc(dp[i&1][k][s|4],dp[cur][j][s]);
}
}
}
}
}
cur^=1;
}
for(int i=1;i<=62;i++)inc(ans,dp[n&1][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: 0ms
memory: 3868kb
input:
4 a?0B
output:
86
result:
ok single line: '86'
Test #2:
score: -100
Wrong Answer
time: 30ms
memory: 4048kb
input:
100000 1kQOIXnSMDlMqJcA8Ae6ov3DfVWAk0I16BgJ3tW1A6ERqBOy4kYizhqPUAU9DrUK26oQ8tgVQW0sRIcg0J2moqS6rRc5lh6QBtzFNfVDvU?sHilmsDIsywXDEeCy8bFracBGSwWNnkLa49E7d9JNXS1QsWPRoYV6IwSvdLdeYMczFmy7G56rxql6YXsX8AaWRLfxqukM5ovPzuSCTpSpN5?OaCE8xb8xu7xJ4A2pOHTOxe1EStiTlWMLeoM5qW6ULwCK4Dtcru8sjqaTilMzLvU27DcJnUhweXT80...
output:
0
result:
wrong answer 1st lines differ - expected: '483479164', found: '0'