結果
問題 | No.1702 count good string |
ユーザー | hayaten |
提出日時 | 2021-10-09 00:33:02 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 139 ms / 2,000 ms |
コード長 | 4,823 bytes |
コンパイル時間 | 2,459 ms |
コンパイル使用メモリ | 216,288 KB |
実行使用メモリ | 15,104 KB |
最終ジャッジ日時 | 2024-07-23 09:14:09 |
合計ジャッジ時間 | 6,706 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,944 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,944 KB |
testcase_12 | AC | 2 ms
6,944 KB |
testcase_13 | AC | 132 ms
15,104 KB |
testcase_14 | AC | 135 ms
14,976 KB |
testcase_15 | AC | 135 ms
15,104 KB |
testcase_16 | AC | 138 ms
14,976 KB |
testcase_17 | AC | 132 ms
14,976 KB |
testcase_18 | AC | 139 ms
14,976 KB |
testcase_19 | AC | 131 ms
15,104 KB |
testcase_20 | AC | 128 ms
14,976 KB |
testcase_21 | AC | 133 ms
15,104 KB |
testcase_22 | AC | 130 ms
14,976 KB |
testcase_23 | AC | 3 ms
6,944 KB |
testcase_24 | AC | 2 ms
6,940 KB |
testcase_25 | AC | 3 ms
6,944 KB |
testcase_26 | AC | 2 ms
6,944 KB |
testcase_27 | AC | 3 ms
6,944 KB |
testcase_28 | AC | 2 ms
6,940 KB |
testcase_29 | AC | 2 ms
6,944 KB |
testcase_30 | AC | 2 ms
6,940 KB |
testcase_31 | AC | 3 ms
6,944 KB |
testcase_32 | AC | 3 ms
6,940 KB |
testcase_33 | AC | 128 ms
14,976 KB |
testcase_34 | AC | 127 ms
15,080 KB |
testcase_35 | AC | 128 ms
14,976 KB |
testcase_36 | AC | 127 ms
15,040 KB |
testcase_37 | AC | 128 ms
15,104 KB |
testcase_38 | AC | 125 ms
14,976 KB |
testcase_39 | AC | 126 ms
15,104 KB |
testcase_40 | AC | 127 ms
15,104 KB |
testcase_41 | AC | 126 ms
15,104 KB |
testcase_42 | AC | 124 ms
14,980 KB |
testcase_43 | AC | 129 ms
14,976 KB |
testcase_44 | AC | 129 ms
14,976 KB |
testcase_45 | AC | 2 ms
6,940 KB |
testcase_46 | AC | 2 ms
6,944 KB |
testcase_47 | AC | 2 ms
6,944 KB |
testcase_48 | AC | 2 ms
6,940 KB |
testcase_49 | AC | 2 ms
6,944 KB |
ソースコード
#pragma region Macros // #pragma GCC target("avx2") #pragma GCC optimize("O3") #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = (n - 1); i >= 0; i--) #define ALL(v) v.begin(), v.end() #define pb push_back #define eb emplace_back #define endl "\n" using namespace std; using P = pair<int, int>; using PL = pair<long long, long long>; typedef long long ll; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; const int fx[8] = {0, 1, 1, 1, 0, -1, -1, -1}; const int fy[8] = {1, 1, 0, -1, -1, -1, 0, 1}; // modint: mod 計算を int を扱うように扱える構造体 template<int MOD> struct Fp { long long val; constexpr Fp(long long v = 0) noexcept : val(v % MOD) { if (val < 0) val += MOD; } constexpr int getmod() const { return MOD; } constexpr Fp operator - () const noexcept { return val ? MOD - val : 0; } constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; } constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; } constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; } constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; } constexpr Fp& operator += (const Fp& r) noexcept { val += r.val; if (val >= MOD) val -= MOD; return *this; } constexpr Fp& operator -= (const Fp& r) noexcept { val -= r.val; if (val < 0) val += MOD; return *this; } constexpr Fp& operator *= (const Fp& r) noexcept { val = val * r.val % MOD; return *this; } constexpr Fp& operator /= (const Fp& r) noexcept { long long a = r.val, b = MOD, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b, swap(a, b); u -= t * v, swap(u, v); } val = val * u % MOD; if (val < 0) val += MOD; return *this; } constexpr bool operator == (const Fp& r) const noexcept { return this->val == r.val; } constexpr bool operator != (const Fp& r) const noexcept { return this->val != r.val; } friend constexpr istream& operator >> (istream& is, Fp<MOD>& x) noexcept { is >> x.val; x.val %= MOD; if (x.val < 0) x.val += MOD; return is; } friend constexpr ostream& operator << (ostream& os, const Fp<MOD>& x) noexcept { return os << x.val; } friend constexpr Fp<MOD> modpow(const Fp<MOD>& r, long long n) noexcept { if (n == 0) return 1; if (n < 0) return modpow(modinv(r), -n); auto t = modpow(r, n / 2); t = t * t; if (n & 1) t = t * r; return t; } friend constexpr Fp<MOD> modinv(const Fp<MOD>& r) noexcept { long long a = r.val, b = MOD, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b, swap(a, b); u -= t * v, swap(u, v); } return Fp<MOD>(u); } }; // Binomial Coefficient template<class T> struct BiCoef { vector<T> fact_, inv_, finv_; constexpr BiCoef() {} constexpr BiCoef(int n) noexcept : fact_(n, 1), inv_(n, 1), finv_(n, 1) { init(n); } constexpr void init(int n) noexcept { fact_.assign(n, 1), inv_.assign(n, 1), finv_.assign(n, 1); int MOD = fact_[0].getmod(); for(int i = 2; i < n; i++){ fact_[i] = fact_[i-1] * i; inv_[i] = -inv_[MOD%i] * (MOD/i); finv_[i] = finv_[i-1] * inv_[i]; } } constexpr T com(int n, int k) const noexcept { if (n < k || n < 0 || k < 0) return 0; return fact_[n] * finv_[k] * finv_[n-k]; } constexpr T fact(int n) const noexcept { if (n < 0) return 0; return fact_[n]; } constexpr T inv(int n) const noexcept { if (n < 0) return 0; return inv_[n]; } constexpr T finv(int n) const noexcept { if (n < 0) return 0; return finv_[n]; } }; using mint = Fp<1000000007>; void solve() { int n; cin >> n; string s; cin >> s; string t = "yukicoder"; string f = "yukicoder"; mint ans = 0; rep(k, 10){ vector<vector<mint>> dp(n + 4, vector<mint>(10, 0)); dp[0][0] = 1; rep(i, n){ rep(j, 10){ dp[i+1][j] += dp[i][j]; if(s[i] == t[j])dp[i+1][j+1] += dp[i][j]; } } ans += dp[n][9]; if(k == 9)break; t = f; t[k] = '?'; } cout << ans << endl; } int main() { cin.tie(0); ios::sync_with_stdio(false); int t = 1; while(t--) solve(); }