QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#522703#8080. Pa?sWorDfengWA 27ms3728kbC++205.6kb2024-08-17 11:56:332024-08-17 11:56:33

Judging History

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

  • [2024-08-17 11:56:33]
  • 评测
  • 测评结果:WA
  • 用时:27ms
  • 内存:3728kb
  • [2024-08-17 11:56:33]
  • 提交

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];
                    sum[i % 2][j] %= mod;
                }
            }
        }
        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];
                    sum[i % 2][j] %= mod;
                }
            }
        }
        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];
                    sum[i % 2][j] %= mod;
                }
            }
            for (int j = 0; j < (1 << 3); ++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 << 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];
                    sum[i % 2][j] %= mod;
                }
            }
        }
        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];
                        sum[i % 2][j] %= mod;
                    }
                }
            }
            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];
                        sum[i % 2][j] %= mod;
                    }
                }
            }
            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];
                        sum[i % 2][j] %= mod;
                    }
                }
            }
        }
    }
    cout << sum[(s.size() - 1) % 2][(1 << 3) - 1] << endl;
    return 0;
}

詳細信息

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: 27ms
memory: 3728kb

input:

100000
1kQOIXnSMDlMqJcA8Ae6ov3DfVWAk0I16BgJ3tW1A6ERqBOy4kYizhqPUAU9DrUK26oQ8tgVQW0sRIcg0J2moqS6rRc5lh6QBtzFNfVDvU?sHilmsDIsywXDEeCy8bFracBGSwWNnkLa49E7d9JNXS1QsWPRoYV6IwSvdLdeYMczFmy7G56rxql6YXsX8AaWRLfxqukM5ovPzuSCTpSpN5?OaCE8xb8xu7xJ4A2pOHTOxe1EStiTlWMLeoM5qW6ULwCK4Dtcru8sjqaTilMzLvU27DcJnUhweXT80...

output:

241739582

result:

wrong answer 1st lines differ - expected: '483479164', found: '241739582'