QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#522697 | #8080. Pa?sWorD | feng | WA | 24ms | 3716kb | C++20 | 5.5kb | 2024-08-17 11:33:40 | 2024-08-17 11:33:40 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define ll long long
#define PII std::pair<int,int>
using namespace std;
const int maxn = 1e5 + 5, mod = 998244353;
int dp[2][150][10], sum[2][10];
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
//cout << fixed << setprecision(2);
int N; cin >> N;
string s; cin >> s;
if (isupper(s[0])) dp[0][s[0]][1 << 2] = 1, sum[0][1 << 2] = 1;
else if (isdigit(s[0])) dp[0][s[0]][1] = 1, sum[0][1] = 1;
else if (islower(s[0])) dp[0][s[0]][1 << 1] = dp[0][toupper(s[0])][1 << 2] = 1, sum[0][1 << 1] = sum[0][1 << 2] = 1;
else {
for (int i = 0; i < 10; ++i) dp[0]['0' + i][1] = 1;
sum[0][1] = 10;
for (int i = 0; i < 26; ++i) dp[0]['a' + i][1 << 1] = 1;
for (int i = 0; i < 26; ++i) dp[0]['A' + i][1 << 2] = 1;
sum[0][1 << 1] = sum[0][1 << 2] = 26;
}
for (int i = 1; i < s.size(); ++i) {
for (int j = 0; j < 150; ++j) {
for (int k = 0; k < 8; ++k) {
dp[i % 2][j][k] = 0;
}
}
for (int j = 0; j < 8; ++j) sum[i % 2][j] = 0;
if (isupper(s[i])) {
for (int j = 0; j < (1 << 3); ++j) {
if (j & (1 << 2)) {
dp[i % 2][s[i]][j] += sum[(i - 1) % 2][j], dp[i % 2][s[i]][j] %= mod;
dp[i % 2][s[i]][j] += sum[(i - 1) % 2][j - (1 << 2)], dp[i % 2][s[i]][j] %= mod;
dp[i % 2][s[i]][j] = dp[i % 2][s[i]][j] + mod - dp[(i - 1) % 2][s[i]][j];
dp[i % 2][s[i]][j] %= mod;
sum[i % 2][j] += dp[i % 2][s[i]][j];
}
}
}
else if (isdigit(s[i])) {
for (int j = 0; j < (1 << 3); ++j) {
if (j & 1) {
dp[i % 2][s[i]][j] += sum[(i - 1) % 2][j], dp[i % 2][s[i]][j] %= mod;
dp[i % 2][s[i]][j] += sum[(i - 1) % 2][j - 1], dp[i % 2][s[i]][j] %= mod;
dp[i % 2][s[i]][j] = dp[i % 2][s[i]][j] + mod - dp[(i - 1) % 2][s[i]][j];
dp[i % 2][s[i]][j] %= mod;
sum[i % 2][j] += dp[i % 2][s[i]][j];
}
}
}
else if (islower(s[i])) {
for (int j = 0; j < (1 << 3); ++j) {
if (j & (1 << 1)) {
dp[i % 2][s[i]][j] += sum[(i - 1) % 2][j], dp[i % 2][s[i]][j] %= mod;
dp[i % 2][s[i]][j] += sum[(i - 1) % 2][j - (1 << 1)], dp[i % 2][s[i]][j] %= mod;
dp[i % 2][s[i]][j] = dp[i % 2][s[i]][j] + mod - dp[(i - 1) % 2][s[i]][j];
dp[i % 2][s[i]][j] %= mod;
sum[i % 2][j] += dp[i % 2][s[i]][j];
}
if (j & (1 << 2)) {
s[i] = toupper(s[i]);
dp[i % 2][s[i]][j] += sum[(i - 1) % 2][j], dp[i % 2][s[i]][j] %= mod;
dp[i % 2][s[i]][j] += sum[(i - 1) % 2][j - (1 << 2)], dp[i % 2][s[i]][j] %= mod;
dp[i % 2][s[i]][j] = dp[i % 2][s[i]][j] + mod - dp[(i - 1) % 2][s[i]][j];
dp[i % 2][s[i]][j] %= mod;
sum[i % 2][j] += dp[i % 2][s[i]][j];
}
}
}
else {
for (int a = 0; a < 10; ++a) {
for (int j = 0; j < (1 << 3); ++j) {
if (j & 1) {
s[i] = '0' + a;
dp[i % 2][s[i]][j] += sum[(i - 1) % 2][j], dp[i % 2][s[i]][j] %= mod;
dp[i % 2][s[i]][j] += sum[(i - 1) % 2][j - 1], dp[i % 2][s[i]][j] %= mod;
dp[i % 2][s[i]][j] = dp[i % 2][s[i]][j] + mod - dp[(i - 1) % 2][s[i]][j];
dp[i % 2][s[i]][j] %= mod;
sum[i % 2][j] += dp[i % 2][s[i]][j];
}
}
}
for (int a = 0; a < 26; ++a) {
for (int j = 0; j < (1 << 3); ++j) {
if (j & (1 << 1)) {
s[i] = 'a' + a;
dp[i % 2][s[i]][j] += sum[(i - 1) % 2][j], dp[i % 2][s[i]][j] %= mod;
dp[i % 2][s[i]][j] += sum[(i - 1) % 2][j - (1 << 1)], dp[i % 2][s[i]][j] %= mod;
dp[i % 2][s[i]][j] = dp[i % 2][s[i]][j] + mod - dp[(i - 1) % 2][s[i]][j];
dp[i % 2][s[i]][j] %= mod;
sum[i % 2][j] += dp[i % 2][s[i]][j];
}
}
}
for (int a = 0; a < 26; ++a) {
for (int j = 0; j < (1 << 3); ++j) {
if (j & (1 << 2)) {
s[i] = 'A' + a;
dp[i % 2][s[i]][j] += sum[(i - 1) % 2][j], dp[i % 2][s[i]][j] %= mod;
dp[i % 2][s[i]][j] += sum[(i - 1) % 2][j - (1 << 2)], dp[i % 2][s[i]][j] %= mod;
dp[i % 2][s[i]][j] = dp[i % 2][s[i]][j] + mod - dp[(i - 1) % 2][s[i]][j];
dp[i % 2][s[i]][j] %= mod;
sum[i % 2][j] += dp[i % 2][s[i]][j];
}
}
}
}
}
int ans = 0;
for (int i = 0; i < 10; ++i) ans += dp[(N - 1) % 2]['0' + i][(1 << 3) - 1], ans %= mod;
for (int i = 0; i < 26; ++i) ans += dp[(N - 1) % 2]['a' + i][(1 << 3) - 1], ans %= mod;
for (int i = 0; i < 26; ++i) ans += dp[(N - 1) % 2]['A' + i][(1 << 3) - 1], ans %= mod;
cout << ans << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
input:
4 a?0B
output:
86
result:
ok single line: '86'
Test #2:
score: -100
Wrong Answer
time: 24ms
memory: 3716kb
input:
100000 1kQOIXnSMDlMqJcA8Ae6ov3DfVWAk0I16BgJ3tW1A6ERqBOy4kYizhqPUAU9DrUK26oQ8tgVQW0sRIcg0J2moqS6rRc5lh6QBtzFNfVDvU?sHilmsDIsywXDEeCy8bFracBGSwWNnkLa49E7d9JNXS1QsWPRoYV6IwSvdLdeYMczFmy7G56rxql6YXsX8AaWRLfxqukM5ovPzuSCTpSpN5?OaCE8xb8xu7xJ4A2pOHTOxe1EStiTlWMLeoM5qW6ULwCK4Dtcru8sjqaTilMzLvU27DcJnUhweXT80...
output:
0
result:
wrong answer 1st lines differ - expected: '483479164', found: '0'