QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#743766#8080. Pa?sWorDyhdddWA 30ms3984kbC++142.0kb2024-11-13 19:58:392024-11-13 19:58:44

Judging History

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

  • [2024-11-13 19:58:44]
  • 评测
  • 测评结果:WA
  • 用时:30ms
  • 内存:3984kb
  • [2024-11-13 19:58:39]
  • 提交

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=1;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: 3948kb

input:

4
a?0B

output:

86

result:

ok single line: '86'

Test #2:

score: -100
Wrong Answer
time: 30ms
memory: 3984kb

input:

100000
1kQOIXnSMDlMqJcA8Ae6ov3DfVWAk0I16BgJ3tW1A6ERqBOy4kYizhqPUAU9DrUK26oQ8tgVQW0sRIcg0J2moqS6rRc5lh6QBtzFNfVDvU?sHilmsDIsywXDEeCy8bFracBGSwWNnkLa49E7d9JNXS1QsWPRoYV6IwSvdLdeYMczFmy7G56rxql6YXsX8AaWRLfxqukM5ovPzuSCTpSpN5?OaCE8xb8xu7xJ4A2pOHTOxe1EStiTlWMLeoM5qW6ULwCK4Dtcru8sjqaTilMzLvU27DcJnUhweXT80...

output:

0

result:

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