結果

問題 No.2872 Depth of the Parentheses
ユーザー 👑 seekworserseekworser
提出日時 2024-07-16 03:32:35
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 888 bytes
コンパイル時間 8,317 ms
コンパイル使用メモリ 334,836 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-06 20:50:35
合計ジャッジ時間 8,521 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 RE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/modint.hpp>

#include "testlib.h"
using namespace std;
using mint = atcoder::modint998244353;

int main() {
    registerValidation();
    int x = inf.readInt(0, 100);
    inf.readSpace();
    int k = inf.readInt(1, 10);
    inf.readEoln();
    inf.readEof();
    mint ans = 0;
    for (int bit = 0; bit < (1 << 2 * k); bit++) {
        auto depth = [&]() -> mint {
            int cnt = 0;
            int ans = 0;
            for (int i = 0; i < 2*k; i++) {
                if ((bit >> i) & 1)
                    cnt++;
                else
                    cnt--;
                if (cnt < 0) return 0;
                ans = max(ans, cnt);
            }
            return cnt == 0 ? ans : 0;
        };
        ans += depth();
    }
    mint p = mint(x) / 100;
    ans *= p.pow(k) * (mint(1) - p).pow(k);
    cout << ans.val() << endl;
}
0