結果

問題 No.1702 count good string
ユーザー tabae326tabae326
提出日時 2021-10-08 22:22:49
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 1,455 bytes
コンパイル時間 2,115 ms
コンパイル使用メモリ 203,020 KB
実行使用メモリ 11,488 KB
最終ジャッジ日時 2023-09-30 10:48:21
合計ジャッジ時間 4,263 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
11,140 KB
testcase_01 AC 5 ms
11,244 KB
testcase_02 AC 5 ms
11,292 KB
testcase_03 AC 6 ms
11,064 KB
testcase_04 AC 6 ms
11,236 KB
testcase_05 AC 5 ms
11,112 KB
testcase_06 AC 5 ms
11,124 KB
testcase_07 AC 5 ms
11,156 KB
testcase_08 AC 5 ms
11,260 KB
testcase_09 AC 5 ms
11,144 KB
testcase_10 AC 6 ms
11,264 KB
testcase_11 AC 6 ms
11,108 KB
testcase_12 AC 6 ms
11,060 KB
testcase_13 AC 9 ms
11,268 KB
testcase_14 AC 9 ms
11,168 KB
testcase_15 AC 9 ms
11,268 KB
testcase_16 AC 9 ms
11,300 KB
testcase_17 AC 9 ms
11,176 KB
testcase_18 AC 9 ms
11,372 KB
testcase_19 AC 9 ms
11,316 KB
testcase_20 AC 9 ms
11,488 KB
testcase_21 AC 9 ms
11,356 KB
testcase_22 AC 9 ms
11,268 KB
testcase_23 AC 5 ms
11,236 KB
testcase_24 AC 5 ms
11,168 KB
testcase_25 AC 5 ms
11,160 KB
testcase_26 AC 5 ms
11,332 KB
testcase_27 AC 6 ms
11,300 KB
testcase_28 AC 5 ms
11,180 KB
testcase_29 AC 5 ms
11,328 KB
testcase_30 AC 6 ms
11,156 KB
testcase_31 AC 5 ms
11,268 KB
testcase_32 AC 5 ms
11,176 KB
testcase_33 AC 8 ms
11,184 KB
testcase_34 AC 9 ms
11,444 KB
testcase_35 AC 8 ms
11,320 KB
testcase_36 AC 8 ms
11,180 KB
testcase_37 AC 8 ms
11,248 KB
testcase_38 AC 8 ms
11,340 KB
testcase_39 AC 8 ms
11,188 KB
testcase_40 AC 8 ms
11,340 KB
testcase_41 AC 8 ms
11,448 KB
testcase_42 AC 8 ms
11,348 KB
testcase_43 AC 8 ms
11,168 KB
testcase_44 AC 8 ms
11,184 KB
testcase_45 AC 6 ms
11,200 KB
testcase_46 AC 5 ms
11,172 KB
testcase_47 AC 5 ms
11,124 KB
testcase_48 AC 5 ms
11,236 KB
testcase_49 AC 6 ms
11,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
// Ref: https://qiita.com/ysuzuki19/items/d89057d65284ba1a16ac
#define dump(var)  do{std::cerr << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cerr << e << "\n";}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cerr << e << " "; } std::cerr << "\n";}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ std::cerr << "\n"; for(const auto& v : vv){ view(v); } }
template<typename T> void dump_cout(const T& v) { for(long long i = 0; i < v.size(); i++) std::cout << v[i] << (i == v.size()-1 ? "\n" : " "); }

#include <atcoder/modint>
using mint = atcoder::modint1000000007;

#define N 100010
mint dp[N][10][2];

void solve() {
    ll n;
    string s;
    cin >> n >> s;
    assert(n < N);
    string t = "yukicoder";
    dp[0][0][0] = 1;
    rep(i, 0, n) {
        rep(j, 0, 10) {
            rep(k, 0, 2) dp[i+1][j][k] += dp[i][j][k];
        }
        rep(j, 0, 9) {
            if(s[i] == '?') dp[i+1][j+1][1] += dp[i][j][0];
            if(s[i] == t[j]) {
                rep(k, 0, 2) dp[i+1][j+1][k] += dp[i][j][k];
            }
        }
    }
    mint ans = dp[n][9][0] + dp[n][9][1];
    cout << ans.val() << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}
0