結果

問題 No.2872 Depth of the Parentheses
ユーザー 👑 seekworserseekworser
提出日時 2024-07-16 03:32:35
言語 C++17
(gcc 12.3.0 + boost 1.83.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
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 2 ms
6,816 KB
testcase_03 AC 2 ms
6,812 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,948 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 22 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 7 ms
6,944 KB
testcase_11 AC 3 ms
6,944 KB
testcase_12 AC 3 ms
6,940 KB
testcase_13 AC 3 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 23 ms
6,940 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 22 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 23 ms
6,944 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 22 ms
6,940 KB
evil_01.txt RE -
evil_02.txt RE -
evil_03.txt RE -
evil_04.txt RE -
evil_05.txt RE -
権限があれば一括ダウンロードができます

ソースコード

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