結果

問題 No.2388 At Least K-Characters
ユーザー 👑 seekworserseekworser
提出日時 2023-07-21 17:23:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,217 bytes
コンパイル時間 2,109 ms
コンパイル使用メモリ 208,340 KB
実行使用メモリ 77,936 KB
最終ジャッジ日時 2023-09-18 12:51:36
合計ジャッジ時間 7,408 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 1 ms
4,380 KB
testcase_12 WA -
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 178 ms
77,728 KB
testcase_17 AC 177 ms
77,624 KB
testcase_18 AC 177 ms
77,668 KB
testcase_19 AC 176 ms
77,688 KB
testcase_20 AC 181 ms
77,708 KB
testcase_21 AC 187 ms
77,692 KB
testcase_22 AC 185 ms
77,640 KB
testcase_23 AC 186 ms
77,584 KB
testcase_24 AC 180 ms
77,652 KB
testcase_25 AC 177 ms
77,664 KB
testcase_26 AC 183 ms
77,652 KB
testcase_27 AC 182 ms
77,660 KB
testcase_28 AC 184 ms
77,620 KB
testcase_29 AC 181 ms
77,800 KB
testcase_30 AC 179 ms
77,632 KB
testcase_31 AC 177 ms
77,704 KB
testcase_32 AC 175 ms
77,724 KB
testcase_33 AC 177 ms
77,892 KB
testcase_34 AC 182 ms
77,632 KB
testcase_35 AC 187 ms
77,936 KB
testcase_36 AC 182 ms
77,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// line 1 "answer.cpp"
#include <bits/stdc++.h>
#include <atcoder/modint.hpp>
using namespace std;
using mint = atcoder::modint998244353;

int main() {
    int n, m, k;
    string s;
    cin >> n >> m >> k >> s;
    vector dp(m+1, vector<mint>(27, 0));
    vector<bool> seen(26, 0);
    int used = 0;
    dp[0][0] = 1;
    for (int i=0; i<m; i++) {
        for (int j=0; j<=26; j++) {
            mint dpi = dp[i][j];
            if (i < n && j == used) {
                int u = 0;
                for(int l=0; l < s[i] - 'a'; l++) {
                    if (seen[l]) u++;
                }
                dp[i+1][j] += u;
                if (j+1 <= 26) dp[i+1][j+1] += (s[i] - 'a' - u);
                if (seen[s[i] - 'a']) dp[i+1][j] += 1;
                else dp[i+1][j+1] += 1;
                dpi -= 1;
            }
            if (i == n && j == used) dpi -= 1;
            dp[i+1][j] += dpi * j;
            if (j+1 <= 26) dp[i+1][j+1] += dpi * (26 - j);
        }
        if (i < n && !seen[s[i] - 'a']) {
            used++;
            seen[s[i] - 'a'] = true;
        }
    }
    mint ans = 0;
    for (int i=1; i<=m; i++) for (int j=k; j<=26; j++) ans += dp[i][j];
    cout << (ans-1).val() << '\n';
}
0