結果
問題 |
No.1702 count good string
|
ユーザー |
![]() |
提出日時 | 2024-04-13 13:24:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 925 bytes |
コンパイル時間 | 2,059 ms |
コンパイル使用メモリ | 198,712 KB |
最終ジャッジ日時 | 2025-02-21 01:00:00 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 47 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/modint> using namespace std; using mint = atcoder::modint1000000007; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int n; string s; cin >> n >> s; vector dp(10, vector<mint>(2)); string y = "yukicoder"; dp[0][0] = 1; for (int i = 0; i < n; i++) { if (s[i] == '?') { for (int j = 8; j >= 0; j--) { dp[j + 1][1] += dp[j][0]; } continue; } int match = -1; for (int j = 0; j < 9; j++) { if (s[i] == y[j]) { match = j; break; } } if (match == -1) { continue; } dp[match + 1][0] += dp[match][0]; dp[match + 1][1] += dp[match][1]; } mint ans = dp[9][0] + dp[9][1]; cout << ans.val() << endl; }