QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#575804 | #8080. Pa?sWorD | hahahalz# | WA | 17ms | 3704kb | C++20 | 5.2kb | 2024-09-19 16:51:01 | 2024-09-19 16:51:02 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define lb long double
const int Max = 2*(int)1e3,mod = 998244353;
int f[2][130][10],presum[10],sum[10],invaild[10];
void solve() {
int n;cin >> n;
string s;cin >> s;
s = " "+ s;
int t = 0;
sum[0] = 1;
for(int i = 1; i <= n; i++,t = 1-t) {
for(int j = 0; j < 8; j++)presum[j] = sum[j]%mod,sum[j] = 0;
if((s[i]>='A'&&s[i]<='Z')) {
for(int k = 0; k <= 128; k++)
for(int j = 1; j <= 8; j++)f[t][k][j] = 0;
invaild[0] = 1,invaild[1] = 1,invaild[2] = 1,invaild[3] = 1;
if(!invaild[4])f[t][s[i]][4] = (presum[0]-f[1-t][s[i]][0]+presum[4]-f[1-t][s[i]][4])%mod,sum[4] += f[t][s[i]][4];
if(!invaild[5])f[t][s[i]][5] = (presum[1]-f[1-t][s[i]][1]+presum[5]-f[1-t][s[i]][5])%mod,sum[5] += f[t][s[i]][5];
if(!invaild[6])f[t][s[i]][6] = (presum[2]-f[1-t][s[i]][2]+presum[6]-f[1-t][s[i]][6])%mod,sum[6] += f[t][s[i]][6];
if(!invaild[7])f[t][s[i]][7] = (presum[3]-f[1-t][s[i]][3]+presum[7]-f[1-t][s[i]][7])%mod,sum[7] += f[t][s[i]][7];
continue;
}
if((s[i]>='0'&&s[i]<='9')) {
for(int i = 0; i <= 128; i++)
for(int j = 1; j <= 8; j++)f[t][i][j] = 0;
invaild[0] = 1,invaild[2] = 1,invaild[4] = 1,invaild[6] = 1;
if(!invaild[1])f[t][s[i]][1] = (presum[0]-f[1-t][s[i]][0]+presum[1]-f[1-t][s[i]][1])%mod,sum[1] += f[t][s[i]][1];
if(!invaild[3])f[t][s[i]][3] = (presum[2]-f[1-t][s[i]][2]+presum[3]-f[1-t][s[i]][3])%mod,sum[3] += f[t][s[i]][3];
if(!invaild[5])f[t][s[i]][5] = (presum[4]-f[1-t][s[i]][4]+presum[5]-f[1-t][s[i]][5])%mod,sum[5] += f[t][s[i]][5];
if(!invaild[7])f[t][s[i]][7] = (presum[6]-f[1-t][s[i]][6]+presum[7]-f[1-t][s[i]][7])%mod,sum[7] += f[t][s[i]][7];
continue;
}
if((s[i]>='a'&&s[i]<='z')) {
for(int i = 0; i <= 128; i++)
for(int j = 1; j <= 8; j++)f[t][i][j] = 0;
invaild[0] = 1,invaild[1] = 1;
if(!invaild[2])f[t][s[i]][2] = (presum[0]-f[1-t][s[i]][0]+presum[2]-f[1-t][s[i]][2])%mod,sum[2] += f[t][s[i]][2];
if(!invaild[3])f[t][s[i]][3] = (presum[1]-f[1-t][s[i]][1]+presum[3]-f[1-t][s[i]][3])%mod,sum[3] += f[t][s[i]][3];
if(!invaild[6])f[t][s[i]][6] = (presum[4]-f[1-t][s[i]][4]+presum[6]-f[1-t][s[i]][6])%mod,sum[6] += f[t][s[i]][6];
if(!invaild[7])f[t][s[i]][7] = (presum[5]-f[1-t][s[i]][5]+presum[7]-f[1-t][s[i]][7])%mod,sum[7] += f[t][s[i]][7];
s[i] = s[i]-'a'+'A';
if(!invaild[4])f[t][s[i]][4] = (presum[0]-f[1-t][s[i]][0]+presum[4]-f[1-t][s[i]][4])%mod,sum[4] += f[t][s[i]][4];
if(!invaild[5])f[t][s[i]][5] = (presum[1]-f[1-t][s[i]][1]+presum[5]-f[1-t][s[i]][5])%mod,sum[5] += f[t][s[i]][5];
if(!invaild[6])f[t][s[i]][6] = (presum[2]-f[1-t][s[i]][2]+presum[6]-f[1-t][s[i]][6])%mod,sum[6] += f[t][s[i]][6];
if(!invaild[7])f[t][s[i]][7] = (presum[3]-f[1-t][s[i]][3]+presum[7]-f[1-t][s[i]][7])%mod,sum[7] += f[t][s[i]][7];
continue;
}
for(s[i] = (int)'0'; (int)s[i] < 127; s[i] = (char)(s[i]+1)) {
if((s[i]>='A'&&s[i]<='Z')) {
if(!invaild[4])f[t][s[i]][4] = (presum[0]-f[1-t][s[i]][0]+presum[4]-f[1-t][s[i]][4])%mod,sum[4] += f[t][s[i]][4];
if(!invaild[5])f[t][s[i]][5] = (presum[1]-f[1-t][s[i]][1]+presum[5]-f[1-t][s[i]][5])%mod,sum[5] += f[t][s[i]][5];
if(!invaild[6])f[t][s[i]][6] = (presum[2]-f[1-t][s[i]][2]+presum[6]-f[1-t][s[i]][6])%mod,sum[6] += f[t][s[i]][6];
if(!invaild[7])f[t][s[i]][7] = (presum[3]-f[1-t][s[i]][3]+presum[7]-f[1-t][s[i]][7])%mod,sum[7] += f[t][s[i]][7];
continue;
}
if((s[i]>='0'&&s[i]<='9')) {
if(!invaild[1])f[t][s[i]][1] = (presum[0]-f[1-t][s[i]][0]+presum[1]-f[1-t][s[i]][1])%mod,sum[1] += f[t][s[i]][1];
if(!invaild[3])f[t][s[i]][3] = (presum[2]-f[1-t][s[i]][2]+presum[3]-f[1-t][s[i]][3])%mod,sum[3] += f[t][s[i]][3];
if(!invaild[5])f[t][s[i]][5] = (presum[4]-f[1-t][s[i]][4]+presum[5]-f[1-t][s[i]][5])%mod,sum[5] += f[t][s[i]][5];
if(!invaild[7])f[t][s[i]][7] = (presum[6]-f[1-t][s[i]][6]+presum[7]-f[1-t][s[i]][7])%mod,sum[7] += f[t][s[i]][7];
continue;
}
if((s[i]>='a'&&s[i]<='z')) {
if(!invaild[2])f[t][s[i]][2] = (presum[0]-f[1-t][s[i]][0]+presum[2]-f[1-t][s[i]][2])%mod,sum[2] += f[t][s[i]][2];
if(!invaild[3])f[t][s[i]][3] = (presum[1]-f[1-t][s[i]][1]+presum[3]-f[1-t][s[i]][3])%mod,sum[3] += f[t][s[i]][3];
if(!invaild[6])f[t][s[i]][6] = (presum[4]-f[1-t][s[i]][4]+presum[6]-f[1-t][s[i]][6])%mod,sum[6] += f[t][s[i]][6];
if(!invaild[7])f[t][s[i]][7] = (presum[5]-f[1-t][s[i]][5]+presum[7]-f[1-t][s[i]][7])%mod,sum[7] += f[t][s[i]][7];
}
}
}
cout << sum[7];
}
signed main() {
#ifdef ACM_LOCAL
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
int t=1;
//cin>>t;
while(t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3556kb
input:
4 a?0B
output:
86
result:
ok single line: '86'
Test #2:
score: -100
Wrong Answer
time: 17ms
memory: 3704kb
input:
100000 1kQOIXnSMDlMqJcA8Ae6ov3DfVWAk0I16BgJ3tW1A6ERqBOy4kYizhqPUAU9DrUK26oQ8tgVQW0sRIcg0J2moqS6rRc5lh6QBtzFNfVDvU?sHilmsDIsywXDEeCy8bFracBGSwWNnkLa49E7d9JNXS1QsWPRoYV6IwSvdLdeYMczFmy7G56rxql6YXsX8AaWRLfxqukM5ovPzuSCTpSpN5?OaCE8xb8xu7xJ4A2pOHTOxe1EStiTlWMLeoM5qW6ULwCK4Dtcru8sjqaTilMzLvU27DcJnUhweXT80...
output:
-514765189
result:
wrong answer 1st lines differ - expected: '483479164', found: '-514765189'