QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#628349 | #8080. Pa?sWorD | Foedere0 | TL | 194ms | 5508kb | C++20 | 3.8kb | 2024-10-10 19:46:10 | 2024-10-10 19:46:10 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
typedef pair<int, int> PII;
int mod = 998244353;
const int N = 100010;
int n;
int dp[2][110][10];
int a[N];
int ty[N];
int into(char k)
{
if (k >= '0' && k <= '9')
return 0;
if (k >= 'A' && k <= 'Z')
return 1;
if (k >= 'a' && k <= 'z')
return 2;
return 3;
}
int get(char k)
{
if (k >= '0' && k <= '9')
return k - '0';
if (k >= 'A' && k <= 'Z')
return k - 'A' + 10;
if (k >= 'a' && k <= 'z')
return k - 'a' + 36;
return 63;
}
int getmod(int x)
{
if (x >= mod)
{
x -= mod;
}
return x;
}
void solve()
{
cin >> n;
string s;
cin >> s;
s = ' ' + s;
// cout << get('Z') << endl;
for (int i = 1; i <= n; i++)
{
a[i] = get(s[i]);
ty[i] = into(s[i]);
}
int now = 0;
dp[0][0][0] = 1;
for (int i = 1; i <= n; i++)
{
int t = now ^ 1;
if (ty[i] <= 1)
{
for (int k = 0; k < 8; k++)
{
for (int j = 0; j <= 61; j++)
{
if (a[i] == j)
continue;
dp[t][a[i]][k | (1 << ty[i])] += dp[now][j][k];
dp[t][a[i]][k | (1 << ty[i])] = getmod(dp[t][a[i]][k | (1 << ty[i])]);
}
}
}
if (ty[i] == 2)
{
for (int k = 0; k < 8; k++)
{
for (int j = 0; j <= 61; j++)
{
if (a[i] == j)
continue;
dp[t][a[i]][k | (1 << ty[i])] += dp[now][j][k];
dp[t][a[i]][k | (1 << ty[i])] = getmod(dp[t][a[i]][k | (1 << ty[i])]);
}
}
for (int k = 0; k < 8; k++)
{
for (int j = 0; j <= 61; j++)
{
if (a[i] - 26 == j)
continue;
dp[t][a[i] - 26][k | 2] += dp[now][j][k];
dp[t][a[i] - 26][k | 2] = getmod(dp[t][a[i] - 26][k | 2]);
}
}
}
if (ty[i] == 3)
{
for (int k = 0; k < 8; k++)
{
for (int j = 0; j <= 61; j++)
{
for (int r = 0; r <= 9; r++)
{
if (r == j)
continue;
dp[t][r][k | 1] += dp[now][j][k];
dp[t][r][k | 1] = getmod(dp[t][r][k | 1]);
}
for (int r = 10; r <= 35; r++)
{
if (r == j)
continue;
dp[t][r][k | 2] += dp[now][j][k];
dp[t][r][k | 2] = getmod(dp[t][r][k | 2]);
}
for (int r = 36; r <= 61; r++)
{
if (r == j)
continue;
dp[t][r][k | 4] += dp[now][j][k];
dp[t][r][k | 4] = getmod(dp[t][r][k | 4]);
}
}
}
}
for (int j = 0; j < 8; j++)
{
for (int r = 0; r <= 62; r++)
{
dp[now][r][j] = 0;
}
}
now = t;
}
int res = 0;
for (int i = 0; i <= 61; i++)
{
res += dp[now][i][7];
res = getmod(res);
}
cout << getmod(res) << endl;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T = 1;
// cin >> T;
while (T--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3608kb
input:
4 a?0B
output:
86
result:
ok single line: '86'
Test #2:
score: 0
Accepted
time: 192ms
memory: 5300kb
input:
100000 1kQOIXnSMDlMqJcA8Ae6ov3DfVWAk0I16BgJ3tW1A6ERqBOy4kYizhqPUAU9DrUK26oQ8tgVQW0sRIcg0J2moqS6rRc5lh6QBtzFNfVDvU?sHilmsDIsywXDEeCy8bFracBGSwWNnkLa49E7d9JNXS1QsWPRoYV6IwSvdLdeYMczFmy7G56rxql6YXsX8AaWRLfxqukM5ovPzuSCTpSpN5?OaCE8xb8xu7xJ4A2pOHTOxe1EStiTlWMLeoM5qW6ULwCK4Dtcru8sjqaTilMzLvU27DcJnUhweXT80...
output:
483479164
result:
ok single line: '483479164'
Test #3:
score: 0
Accepted
time: 194ms
memory: 5508kb
input:
100000 hSilkqEibN5P3zsoXdREarzoRC94XflJB6OzigUfyu2ndtAvNBIeRyziL2k7DvqK5zs7O8Mjkw?LP6zyrT7?XLUJCdD7hTkhTmExwPNt58rb1ACY50PRJNBKktdq?m1CMQrFStmBh3DL5Uq2dLaQlByUpjK7gTHC78NclKgCJBrL37F?38KaQ?WVsMWzj4h4HCExAwXAo9M9s71nf0JyAFPs0d4tiPODAFboNfVbSldtpBKTtBznz1kLc7VKGPUkSFvoWEeEWbKQafX5PNEIJ95Xgi4oFeyBVgo4Y...
output:
647474736
result:
ok single line: '647474736'
Test #4:
score: -100
Time Limit Exceeded
input:
100000 ?t?T?1?I?9?L7v?9?q?s?r?BM?n?6?u?M?n0?fR?G?k?s?RB?vwP?7?7?p?Y0?e?M?T?l?UX6?W?n?uz?D?y?x?1?X?z?N?z?O?8?z?j?Rs?D?p?M?91?u?HJrO?U?T?UN?4?yR1?n?xn?7?K?u?kbmz4?6?s?u?m?y?1?1?9?8Uy?1?Pm?0?x?z?E?y?4?F?zlMtF?e7?lF?r4R?4G?6?J?R?b?s4wc?q?L?3?9?N?zD?S?nJ?BaB?e?G?b?LIoP?H?T?vrC?Y?g?H?re?H?s?Qr?s?sGer?J?H?...