結果

問題 No.1702 count good string
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-01-16 18:04:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 1,117 bytes
コンパイル時間 1,073 ms
コンパイル使用メモリ 114,128 KB
実行使用メモリ 61,980 KB
最終ジャッジ日時 2023-08-30 01:19:46
合計ジャッジ時間 6,805 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 123 ms
61,720 KB
testcase_14 AC 123 ms
61,860 KB
testcase_15 AC 123 ms
61,664 KB
testcase_16 AC 122 ms
61,980 KB
testcase_17 AC 123 ms
61,796 KB
testcase_18 AC 121 ms
61,668 KB
testcase_19 AC 122 ms
61,732 KB
testcase_20 AC 123 ms
61,720 KB
testcase_21 AC 124 ms
61,716 KB
testcase_22 AC 122 ms
61,668 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 3 ms
4,376 KB
testcase_29 AC 3 ms
4,380 KB
testcase_30 AC 3 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 3 ms
4,376 KB
testcase_33 AC 122 ms
61,724 KB
testcase_34 AC 121 ms
61,728 KB
testcase_35 AC 125 ms
61,664 KB
testcase_36 AC 121 ms
61,972 KB
testcase_37 AC 123 ms
61,680 KB
testcase_38 AC 122 ms
61,788 KB
testcase_39 AC 121 ms
61,680 KB
testcase_40 AC 123 ms
61,736 KB
testcase_41 AC 121 ms
61,788 KB
testcase_42 AC 123 ms
61,668 KB
testcase_43 AC 122 ms
61,948 KB
testcase_44 AC 120 ms
61,668 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 AC 1 ms
4,376 KB
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 1 ms
4,380 KB
testcase_49 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;

const long long modc=1e9+7;

int main(){

    long long N;
    cin >> N;
    string S, T="yukicoder";
    cin >> S;
    vector<vector<vector<long long>>> dp(N+1, vector(10, vector<long long>(2)));
    for (int i=0; i<=N; i++) dp[i][0][0] = 1;
    for (int i=1; i<=N; i++){
        for (int j=1; j<=9; j++){
            dp[i][j][0] += dp[i-1][j][0]; dp[i][j][0] %= modc;
            if (S[i-1] == T[j-1]){
                dp[i][j][0] += dp[i-1][j-1][0]; dp[i][j][0] %= modc;
            }

            dp[i][j][1] += dp[i-1][j][1]; dp[i][j][1] %= modc;
            if (S[i-1] == T[j-1]){
                dp[i][j][1] += dp[i-1][j-1][1]; dp[i][j][1] %= modc;
            }
            if (S[i-1] == '?'){
                dp[i][j][1] += dp[i-1][j-1][0]; dp[i][j][1] %= modc;
            }   
        }
    }

    cout << (dp[N][9][0] + dp[N][9][1]) % modc << endl;

    return 0;
}
0