結果

問題 No.1702 count good string
ユーザー yel_ow
提出日時 2025-06-10 05:39:36
言語 C++17(gnu拡張)
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 162 ms / 2,000 ms
コード長 1,071 bytes
コンパイル時間 4,529 ms
コンパイル使用メモリ 257,680 KB
実行使用メモリ 62,028 KB
最終ジャッジ日時 2025-06-10 05:39:47
合計ジャッジ時間 9,313 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #

//#include <monsterenergy>
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int MAX = 1e9;
const int MIN = -1*1e9;
const ll MAXLL = 1e18;
const ll MINLL = -1*1e18;
const string Y = "yukicoder";

int main()
{
    int N; cin >> N;
    string S; cin >> S;
    vector DP(N+1,vector(10,vector<mint>(2)));
    DP[0][0][0] = 1;
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j <= 9; j++)
        {
        	if(j != 9)
        	{
	            if(S[i] == '?')
	            {
	                DP[i+1][j+1][1] += DP[i][j][0];
	            }
	            else if(S[i] == Y[j])
	            {
	                DP[i+1][j+1][0] += DP[i][j][0];
	                DP[i+1][j+1][1] += DP[i][j][1];
	            }
        	}
            DP[i+1][j][1] += DP[i][j][1];
            DP[i+1][j][0] += DP[i][j][0];
        }   
    }
    cout << (DP[N][9][0]+DP[N][9][1]).val() << endl;
    return 0;
}
0