結果
| 問題 | 
                            No.1702 count good string
                             | 
                    
| コンテスト | |
| ユーザー | 
                             bit_kyopro
                         | 
                    
| 提出日時 | 2021-10-08 22:52:03 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 136 ms / 2,000 ms | 
| コード長 | 963 bytes | 
| コンパイル時間 | 2,592 ms | 
| コンパイル使用メモリ | 197,244 KB | 
| 最終ジャッジ日時 | 2025-01-24 23:06:18 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 47 | 
ソースコード
#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;
}
            
            
            
        
            
bit_kyopro