結果
問題 |
No.1702 count good string
|
ユーザー |
|
提出日時 | 2021-10-08 23:39:05 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,018 bytes |
コンパイル時間 | 1,235 ms |
コンパイル使用メモリ | 106,712 KB |
最終ジャッジ日時 | 2025-01-24 23:33:12 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 5 WA * 42 |
ソースコード
#include <algorithm> #include <bitset> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <vector> using namespace std; using ll = long long; #define rep(i, j, n) for (int i = j; i < (n); ++i) #define rrep(i, j, n) for (int i = (n)-1; j <= i; --i) #define all(arr) arr.begin(), arr.end() template <typename T> std::ostream &operator<<(std::ostream &os, std::vector<T> &a) { for (size_t i = 0; i < a.size(); ++i) os << (i > 0 ? " " : "") << a[i]; return os << '\n'; } template <typename T> std::ostream &operator<<(std::ostream &os, pair<T, T> &p) { return os << "{ " << p.first << ", " << p.second << " }" << std::endl; } template <typename T> std::istream &operator>>(std::istream &is, std::vector<T> &a) { for (T &x : a) { is >> x; } return is; } //[[maybe_unused]] constexpr long long MOD = 998244353; [[maybe_unused]] constexpr int MOD = 1000000007; [[maybe_unused]] constexpr int INF = 0x3f3f3f3f; [[maybe_unused]] constexpr long long INFL = 0x3f3f3f3f3f3f3f3fLL; // [l, r) int rec(int l, int r, int d, vector<int> &a) { if (r - l <= 1 || d == -1) { return 0; } if ((a[l] >> d & 1) == (a[r - 1] >> d & 1)) { return rec(l, r, d - 1, a); } int mid = l; while ((a[mid] >> d & 1) == 0) { ++mid; } return min(rec(l, mid, d - 1, a) + r - mid - 1, rec(mid, r, d - 1, a) + mid - l - 1); } ll dp[100005][2][9]; const string yuki = "yukicoder"; int main() { cin.tie(0)->sync_with_stdio(0); int n; cin >> n; string s; cin >> s; dp[0][0][0] = 1; rep(i, 0, n) { rep(j, 0, 9) { if (s[i] == '?') { (dp[i + 1][1][j + 1] += dp[i][0][j]) %= MOD; } else { if (s[i] == yuki[j]) { (dp[i + 1][0][j + 1] += dp[i][0][j]) %= MOD; (dp[i + 1][1][j + 1] += dp[i][1][j]) %= MOD; } } (dp[i + 1][0][j] += dp[i][0][j]) %= MOD; (dp[i + 1][1][j] += dp[i][1][j]) %= MOD; } } cout << (dp[n][1][9] + dp[n][0][9]) % MOD; return 0; }