結果
問題 | No.2872 Depth of the Parentheses |
ユーザー | Today03 |
提出日時 | 2024-09-06 22:18:35 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 2,995 bytes |
コンパイル時間 | 2,981 ms |
コンパイル使用メモリ | 253,724 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-06 22:18:46 |
合計ジャッジ時間 | 9,414 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,940 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,940 KB |
testcase_13 | AC | 2 ms
6,944 KB |
testcase_14 | AC | 1 ms
6,944 KB |
testcase_15 | AC | 2 ms
6,944 KB |
testcase_16 | AC | 2 ms
6,944 KB |
testcase_17 | AC | 1 ms
6,940 KB |
testcase_18 | AC | 2 ms
6,940 KB |
testcase_19 | AC | 2 ms
6,944 KB |
testcase_20 | AC | 2 ms
6,944 KB |
testcase_21 | AC | 2 ms
6,940 KB |
testcase_22 | AC | 2 ms
6,940 KB |
evil_01.txt | MLE | - |
evil_02.txt | MLE | - |
evil_03.txt | MLE | - |
evil_04.txt | MLE | - |
evil_05.txt | MLE | - |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; const int INF = 1e9 + 10; const ll INFL = 4e18; /* dp[i][j][k]:=前からi番目までみていて、現在の深さがjであって、深さの最大値がkであるような確率 */ template <ll MOD> struct ModInt { ll value; ModInt(ll x = 0) { if (x >= 0) { value = x % MOD; } else { value = MOD - (-x) % MOD; } } ModInt operator-() const { return ModInt(-value); } ModInt operator+() const { return ModInt(*this); } ModInt &operator+=(const ModInt &other) { value += other.value; if (value >= MOD) { value -= MOD; } return *this; } ModInt &operator-=(const ModInt &other) { value += MOD - other.value; if (value >= MOD) { value -= MOD; } return *this; } ModInt &operator*=(const ModInt other) { value = value * other.value % MOD; return *this; } ModInt &operator/=(ModInt other) { (*this) *= other.inv(); return *this; } ModInt operator+(const ModInt &other) const { return ModInt(*this) += other; } ModInt operator-(const ModInt &other) const { return ModInt(*this) -= other; } ModInt operator*(const ModInt &other) const { return ModInt(*this) *= other; } ModInt operator/(const ModInt &other) const { return ModInt(*this) /= other; } ModInt pow(ll x) const { ModInt ret(1), mul(value); while (x) { if (x & 1) { ret *= mul; } mul *= mul; x >>= 1; } return ret; } ModInt inv() const { return pow(MOD - 2); } bool operator==(const ModInt &other) const { return value == other.value; } bool operator!=(const ModInt &other) const { return value != other.value; } friend ostream &operator<<(ostream &os, const ModInt &x) { return os << x.value; } friend istream &operator>>(istream &is, ModInt &x) { ll v; is >> v; x = ModInt<MOD>(v); return is; } static constexpr ll get_mod() { return MOD; } }; using Mod998 = ModInt<998244353>; using Mod107 = ModInt<1000000007>; using mint = Mod998; int main() { int X, K; cin >> X >> K; mint up = X, dw = 100 - X; up /= 100; dw /= 100; vector dp(2 * K + 1, vector(2 * K + 10, vector<mint>(2 * K + 10))); dp[0][0][0] = 1; for (int i = 0; i < 2 * K; i++) { for (int j = 0; j <= i; j++) { for (int k = 0; k <= i; k++) { dp[i + 1][j + 1][max(k, j + 1)] += dp[i][j][k] * up; if (j > 0) dp[i + 1][j - 1][k] += dp[i][j][k] * dw; } } } mint ans = 0; for (int i = 0; i <= 2 * K; i++) ans += dp[2 * K][0][i] * i; cout << ans << endl; }