結果

問題 No.2031 Colored Brackets
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2022-08-06 02:42:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 683 bytes
コンパイル時間 2,006 ms
コンパイル使用メモリ 199,184 KB
実行使用メモリ 74,688 KB
最終ジャッジ日時 2023-10-14 04:51:28
合計ジャッジ時間 3,852 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 12 ms
41,564 KB
testcase_05 AC 8 ms
28,168 KB
testcase_06 AC 9 ms
33,264 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 15 ms
54,248 KB
testcase_09 AC 18 ms
62,636 KB
testcase_10 AC 20 ms
71,404 KB
testcase_11 AC 17 ms
61,344 KB
testcase_12 AC 22 ms
73,388 KB
testcase_13 AC 14 ms
51,628 KB
testcase_14 AC 22 ms
74,688 KB
testcase_15 AC 22 ms
74,592 KB
testcase_16 AC 22 ms
74,428 KB
testcase_17 AC 25 ms
74,528 KB
testcase_18 AC 19 ms
74,472 KB
testcase_19 AC 18 ms
68,228 KB
testcase_20 AC 14 ms
54,104 KB
testcase_21 AC 13 ms
55,872 KB
testcase_22 AC 15 ms
57,740 KB
testcase_23 AC 18 ms
73,560 KB
testcase_24 AC 2 ms
4,352 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 1 ms
4,352 KB
testcase_30 AC 1 ms
4,352 KB
testcase_31 AC 4 ms
11,852 KB
testcase_32 AC 1 ms
4,348 KB
testcase_33 AC 3 ms
9,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main () {
    ll m = 998244353;
    int N;
    string s;
    cin >> N >> s;
    ll dp[3030][3030];
    for (int i = 0; i <= N; i ++) {
        for (int j = 0; j <= N; j ++) {
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;
    int now = 0;
    for (int i = 1; i <= N; i ++) {
        int x = (s[i - 1] == '(' ? 1 : -1);
        now += x;
        for (int j = 0; j <= now; j ++) {
            dp[i][j] = dp[i - 1][j];
            if (0 <= j - x && j - x <= N) {
                dp[i][j] += dp[i - 1][j - x];
                dp[i][j] %= m;
            }
        }
    }
    cout << dp[N][0] << endl;
}
0