結果

問題 No.2872 Depth of the Parentheses
コンテスト
ユーザー seekworser
提出日時 2024-07-16 03:32:35
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.89.0)
コンパイル:
g++-12 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 888 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 10,677 ms
コンパイル使用メモリ 337,748 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-02-23 12:23:48
合計ジャッジ時間 11,099 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 RE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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