結果

問題 No.2388 At Least K-Characters
ユーザー 👑 seekworserseekworser
提出日時 2023-01-28 18:21:54
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,180 bytes
コンパイル時間 3,107 ms
コンパイル使用メモリ 251,908 KB
実行使用メモリ 814,936 KB
最終ジャッジ日時 2023-09-18 12:50:14
合計ジャッジ時間 7,041 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 WA -
testcase_02 RE -
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 RE -
testcase_08 AC 2 ms
4,380 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 MLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0, i##_len = ll(n); i < i##_len; ++i) // 0 から n-1 まで昇順

int main() {
    int n,m,k;
    cin >> n >> m >> k;
    string s;
    cin >> s;
    int bmax = 1 << 5;
    vector dp(m+1, vector(bmax, vector<ll>(2, 0)));
    dp[0][0][0] = 1;
    rep(i, m) {
        if (i < n) {
            rep(b, bmax) {
                rep(j, s[i] - 'a') {
                    int bn = b | 1 << j;
                    dp[i+1][bn][1] += dp[i][b][0];
                    dp[i+1][bn][1] %= 998244353;
                }
                int bn = b | 1 << (s[i] - 'a');
                dp[i+1][bn][0] += dp[i][b][0];
                dp[i+1][bn][0] %= 998244353;
            }
        }

        rep(b, bmax) {
            rep(j, 5) {
                int bn = b | 1 << j;
                dp[i+1][bn][1] += dp[i][b][1];
                dp[i+1][bn][1] %= 998244353;
            }
        }
    }
    ll ans = 0;
    rep(i, m+1) rep(b, bmax) rep(j, 2) {
        if (i == n && j == 0) continue;
        if (__popcount(b) >= k) ans += dp[i][b][j];
        ans %= 998244353;
    }
    cout << ans << endl;
}
0