結果
問題 | No.2388 At Least K-Characters |
ユーザー | shobonvip |
提出日時 | 2023-07-21 22:11:36 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 169 ms / 4,000 ms |
コード長 | 1,442 bytes |
コンパイル時間 | 4,445 ms |
コンパイル使用メモリ | 263,052 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-18 12:53:33 |
合計ジャッジ時間 | 8,623 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 1 ms
4,376 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | AC | 1 ms
4,376 KB |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 1 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,380 KB |
testcase_10 | AC | 1 ms
4,376 KB |
testcase_11 | AC | 2 ms
4,380 KB |
testcase_12 | AC | 1 ms
4,376 KB |
testcase_13 | AC | 2 ms
4,376 KB |
testcase_14 | AC | 2 ms
4,376 KB |
testcase_15 | AC | 2 ms
4,376 KB |
testcase_16 | AC | 140 ms
4,376 KB |
testcase_17 | AC | 156 ms
4,376 KB |
testcase_18 | AC | 138 ms
4,376 KB |
testcase_19 | AC | 139 ms
4,376 KB |
testcase_20 | AC | 149 ms
4,380 KB |
testcase_21 | AC | 169 ms
4,380 KB |
testcase_22 | AC | 168 ms
4,380 KB |
testcase_23 | AC | 166 ms
4,376 KB |
testcase_24 | AC | 155 ms
4,376 KB |
testcase_25 | AC | 139 ms
4,376 KB |
testcase_26 | AC | 160 ms
4,380 KB |
testcase_27 | AC | 156 ms
4,376 KB |
testcase_28 | AC | 164 ms
4,380 KB |
testcase_29 | AC | 151 ms
4,376 KB |
testcase_30 | AC | 147 ms
4,376 KB |
testcase_31 | AC | 143 ms
4,380 KB |
testcase_32 | AC | 139 ms
4,380 KB |
testcase_33 | AC | 139 ms
4,376 KB |
testcase_34 | AC | 163 ms
4,376 KB |
testcase_35 | AC | 166 ms
4,376 KB |
testcase_36 | AC | 158 ms
4,376 KB |
ソースコード
#include<bits/stdc++.h> #include<atcoder/all> using namespace std; using namespace atcoder; typedef modint998244353 mint; typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) template <typename T> bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template <typename T> bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } int main(){ // KETA DP // small ga kakutei siteiruka? // onaji nara? int n, m, k; cin >> n >> m >> k; string s; cin >> s; vector<mint> dp0(27); // small vector<mint> dp1(27); // not small int tmp = 0; vector<bool> snow(26); mint ans = 0; rep(num,0,m){ vector<mint> ndp0(27); // small vector<mint> ndp1(27); // not small rep(j,0,27){ if (j+1 <= 26) ndp0[j+1] += dp0[j] * (26-j); ndp0[j] += dp0[j] * j; } if (num < n){ rep(j,0,(int)(s[num] - 'a')){ if (snow[j]) ndp0[tmp]++; else ndp0[tmp+1]++; //rep(k,0,27){ // if (snow[j]) ndp0[k] += dp1[k]; // else ndp0[k+1] += dp1[k]; // } } if (snow[s[num] - 'a']) ndp1[tmp]++; else ndp1[tmp+1]++; if (!snow[s[num] - 'a']) tmp++; snow[s[num] - 'a'] = true; } dp0 = ndp0; dp1 = ndp1; rep(i,k,27){ ans += dp0[i]; if (num < n-1) ans += dp1[i]; } //cout << ans.val() << '\n'; } //if (tmp >= k) ans--; cout << ans.val() << '\n'; }