結果
問題 | No.1702 count good string |
ユーザー | tonyu0 |
提出日時 | 2021-10-08 23:39:05 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,018 bytes |
コンパイル時間 | 983 ms |
コンパイル使用メモリ | 108,008 KB |
実行使用メモリ | 17,876 KB |
最終ジャッジ日時 | 2023-09-30 13:54:31 |
合計ジャッジ時間 | 3,395 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | AC | 1 ms
4,380 KB |
testcase_46 | AC | 1 ms
4,376 KB |
testcase_47 | AC | 2 ms
4,380 KB |
testcase_48 | AC | 2 ms
4,376 KB |
testcase_49 | AC | 1 ms
4,380 KB |
ソースコード
#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; }