QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#628441#8080. Pa?sWorDFoedere0TL 165ms4692kbC++204.5kb2024-10-10 20:14:452024-10-10 20:14:48

Judging History

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

  • [2024-10-10 20:14:48]
  • 评测
  • 测评结果:TL
  • 用时:165ms
  • 内存:4692kb
  • [2024-10-10 20:14:45]
  • 提交

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;
    // scanf("%s", s + 1);
    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;
    if (ty[1] <= 2)
    {
        dp[0][a[1]][0 | (1 << ty[1])] = 1;
        if (ty[1] == 2)
        {
            dp[0][a[1] - 26][0 | 2] = 1;
        }
    }
    if (ty[1] == 3)
    {
        for (int r = 0; r <= 9; r++)
        {
            dp[0][r][1] = 1;
        }
        for (int r = 10; r <= 35; r++)
        {
            dp[0][r][2] = 1;
        }
        for (int r = 36; r <= 61; r++)
        {
            dp[0][r][4] = 1;
        }
    }
    for (int i = 2; 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)
                    {
                        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 (a[i] - 26 != j)
                    {
                        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]);
                    }
                }
            }
            /*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(false), cin.tie(0), cout.tie(0);
    int T = 1;
    // cin >> T;
    while (T--)
        solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3572kb

input:

4
a?0B

output:

86

result:

ok single line: '86'

Test #2:

score: 0
Accepted
time: 165ms
memory: 4472kb

input:

100000
1kQOIXnSMDlMqJcA8Ae6ov3DfVWAk0I16BgJ3tW1A6ERqBOy4kYizhqPUAU9DrUK26oQ8tgVQW0sRIcg0J2moqS6rRc5lh6QBtzFNfVDvU?sHilmsDIsywXDEeCy8bFracBGSwWNnkLa49E7d9JNXS1QsWPRoYV6IwSvdLdeYMczFmy7G56rxql6YXsX8AaWRLfxqukM5ovPzuSCTpSpN5?OaCE8xb8xu7xJ4A2pOHTOxe1EStiTlWMLeoM5qW6ULwCK4Dtcru8sjqaTilMzLvU27DcJnUhweXT80...

output:

483479164

result:

ok single line: '483479164'

Test #3:

score: 0
Accepted
time: 165ms
memory: 4692kb

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?...

output:


result: