結果
| 問題 |
No.2031 Colored Brackets
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-08-06 02:40:30 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 696 bytes |
| コンパイル時間 | 1,982 ms |
| コンパイル使用メモリ | 194,072 KB |
| 最終ジャッジ日時 | 2025-01-30 18:57:26 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 4 |
| other | WA * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main () {
ll m = 998244353;
int N;
string s;
cin >> s;
N = s.size();
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;
}