結果

問題 No.1702 count good string
ユーザー bit_kyoprobit_kyopro
提出日時 2021-10-08 22:52:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 963 bytes
コンパイル時間 2,172 ms
コンパイル使用メモリ 204,116 KB
実行使用メモリ 10,448 KB
最終ジャッジ日時 2023-09-30 12:03:29
合計ジャッジ時間 6,611 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
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 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 127 ms
10,128 KB
testcase_14 AC 127 ms
10,300 KB
testcase_15 AC 127 ms
10,116 KB
testcase_16 AC 127 ms
10,292 KB
testcase_17 AC 126 ms
10,244 KB
testcase_18 AC 121 ms
10,300 KB
testcase_19 AC 127 ms
10,224 KB
testcase_20 AC 126 ms
10,124 KB
testcase_21 AC 127 ms
10,236 KB
testcase_22 AC 129 ms
10,232 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 3 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 119 ms
10,232 KB
testcase_34 AC 113 ms
10,224 KB
testcase_35 AC 119 ms
10,184 KB
testcase_36 AC 120 ms
10,296 KB
testcase_37 AC 113 ms
10,448 KB
testcase_38 AC 121 ms
10,180 KB
testcase_39 AC 113 ms
10,180 KB
testcase_40 AC 118 ms
10,300 KB
testcase_41 AC 123 ms
10,296 KB
testcase_42 AC 122 ms
10,236 KB
testcase_43 AC 109 ms
10,296 KB
testcase_44 AC 117 ms
10,184 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 2 ms
4,376 KB
testcase_48 AC 1 ms
4,376 KB
testcase_49 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;


int main() {
    int n; cin >> n;
    int mod = 1000000007;
    string s; cin >> s;
    string y = "yukicoder";
    string t = "yukicoder";
    int m = y.size();
    long long ans = 0;
    for (int k=0; k<10; k++) {
        vector<vector<int>> dp(n+1, vector<int>(m+1, 0));
        for (int i=0; i<=n; i++) {
            for (int j=0; j<=m; j++) {
                if (j == 0) {
                    dp[i][j] = 1;
                    continue;
                }
                if (i == 0) {
                    dp[i][j] = 0;
                    continue;
                }
                dp[i][j] += dp[i-1][j];
                if (s[i-1] == y[j-1]) {
                    dp[i][j] += dp[i-1][j-1];
                }
                dp[i][j] %= mod;
            }
        }
    
        ans += dp[n][m];
        ans %= mod;

        y[k] = '?';
        if (k) y[k-1] = t[k-1];
       
    }
    cout << ans << endl;
}
0