QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#546035 | #8080. Pa?sWorD | rerebornzhou | WA | 241ms | 3704kb | C++14 | 3.3kb | 2024-09-03 19:06:00 | 2024-09-03 19:06:01 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define int long long
#define ull unsigned long long
#define a first
#define b second
#define pi pair<int,int>
const int N=1e5+10;
const int INF=1e18;
const int mod=998244353;
int dp[2][70][2][2][2];
int sum[70][2][2][2];
int ss[2][2][2];
void solve(){
int n;
cin>>n;
string s;
cin>>s;
s=' '+s;
auto judge = [&](char t){
if(t>='a'&&t<='z'){
return t-'a'+1+10;
}
else if(t>='0'&&t<='9'){
return t-'0'+1;
}
else{
return t-'A'+1+36;
}
};
int now=1,old=0;
dp[old][0][0][0][0]=1;
swap(old,now);
for(int i=1;i<=n;i++){
swap(old,now);
if(s[i]>='a'&&s[i]<='z'){
for(int j=0;j<=62;j++){
for(int k1=0;k1<=1;k1++) //数字
for(int k2=0;k2<=1;k2++) //小写
for(int k3=0;k3<=1;k3++){ //大写
if(j!=judge(s[i])){
dp[now][judge(s[i])][k1][1][k3]+=dp[old][j][k1][k2][k3];
dp[now][judge(s[i])][k1][1][k3]%=mod;
}
if(j!=judge(s[i]-'a'+'A')){
dp[now][judge(s[i]-'a'+'A')][k1][k2][1]+=dp[old][j][k1][k2][k3];
dp[now][judge(s[i]-'a'+'A')][k1][k2][1]%=mod;
}
}
}
}
else if((s[i]>='0'&&s[i]<='9')){
for(int j=0;j<=62;j++){
for(int k1=0;k1<=1;k1++) //数字
for(int k2=0;k2<=1;k2++) //小写
for(int k3=0;k3<=1;k3++){ //大写
if(j!=judge(s[i])){
dp[now][judge(s[i])][1][k2][k3]+=dp[old][j][k1][k2][k3];
dp[now][judge(s[i])][1][k2][k3]%=mod;
}
}
}
}
else if(s[i]>='A'&&s[i]<='Z'){
// cout<<i<<"\n";
for(int j=0;j<=62;j++){
for(int k1=0;k1<=1;k1++) //数字
for(int k2=0;k2<=1;k2++) //小写
for(int k3=0;k3<=1;k3++){ //大写
if(j!=judge(s[i])){
dp[now][judge(s[i])][k1][k2][1]+=dp[old][j][k1][k2][k3];
dp[now][judge(s[i])][k1][k2][1]%=mod;
}
}
}
}
else{
memset(sum,0,sizeof sum);
for(int j=0;j<=62;j++){
for(int k1=0;k1<=1;k1++) //数字
for(int k2=0;k2<=1;k2++) //小写
for(int k3=0;k3<=1;k3++){ //大写
sum[j][k1][k2][k3]+=dp[old][j][k1][k2][k3];
ss[k1][k2][k3]+=dp[old][j][k1][k2][k3];
sum[j][k1][k2][k3]%=mod;
ss[k1][k2][k3]%=mod;
}
}
for(int j1=1;j1<=62;j1++){
// for(int j=0;j<=62;j++){
for(int k1=0;k1<=1;k1++) //数字
for(int k2=0;k2<=1;k2++) //小写
for(int k3=0;k3<=1;k3++){ //大写
// if(j!=j1){
// dp[i][j1][1][k2][k3]+=ss-sum[j1];
if(j1<=10) dp[now][j1][1][k2][k3]=(dp[now][j1][1][k2][k3]+(ss[k1][k2][k3]-sum[j1][k1][k2][k3]+mod)%mod)%mod;
else if(j1<=36) dp[now][j1][k1][1][k3]=(dp[now][j1][k1][1][k3]+(ss[k1][k2][k3]-sum[j1][k1][k2][k3]+mod)%mod)%mod;
else dp[now][j1][k1][k2][1]=(dp[now][j1][k1][k2][1]+(ss[k1][k2][k3]-sum[j1][k1][k2][k3]+mod)%mod)%mod;
// }
}
// }
}
}
dp[now][0][0][0][0]=0;
}
int ans=0;
for(int i=1;i<=62;i++){
// for(int k1=0;k1<=1;k1++) //数字
// for(int k2=0;k2<=1;k2++) //小写
// for(int k3=0;k3<=1;k3++){
// cout<<i<<" "<<k1<<" "<<k2<<" "<<k2<<" "<<dp[2][i][k1][k2][k3]<<"\n";
// }
ans+=dp[now][i][1][1][1];
ans%=mod;
}
cout<<ans<<"\n";
}
signed main(){
IOS
int _=1;
// cin>>_;
while(_--){
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3608kb
input:
4 a?0B
output:
86
result:
ok single line: '86'
Test #2:
score: -100
Wrong Answer
time: 241ms
memory: 3704kb
input:
100000 1kQOIXnSMDlMqJcA8Ae6ov3DfVWAk0I16BgJ3tW1A6ERqBOy4kYizhqPUAU9DrUK26oQ8tgVQW0sRIcg0J2moqS6rRc5lh6QBtzFNfVDvU?sHilmsDIsywXDEeCy8bFracBGSwWNnkLa49E7d9JNXS1QsWPRoYV6IwSvdLdeYMczFmy7G56rxql6YXsX8AaWRLfxqukM5ovPzuSCTpSpN5?OaCE8xb8xu7xJ4A2pOHTOxe1EStiTlWMLeoM5qW6ULwCK4Dtcru8sjqaTilMzLvU27DcJnUhweXT80...
output:
89525231
result:
wrong answer 1st lines differ - expected: '483479164', found: '89525231'