結果

問題 No.2031 Colored Brackets
ユーザー olpheolphe
提出日時 2022-08-05 21:39:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 1,107 bytes
コンパイル時間 1,228 ms
コンパイル使用メモリ 131,400 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-13 22:15:09
合計ジャッジ時間 3,070 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 9 ms
4,348 KB
testcase_05 AC 5 ms
4,352 KB
testcase_06 AC 6 ms
4,352 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 AC 16 ms
4,348 KB
testcase_09 AC 21 ms
4,376 KB
testcase_10 AC 27 ms
4,348 KB
testcase_11 AC 20 ms
4,352 KB
testcase_12 AC 29 ms
4,352 KB
testcase_13 AC 13 ms
4,352 KB
testcase_14 AC 30 ms
4,352 KB
testcase_15 AC 30 ms
4,352 KB
testcase_16 AC 30 ms
4,352 KB
testcase_17 AC 32 ms
4,352 KB
testcase_18 AC 26 ms
4,348 KB
testcase_19 AC 22 ms
4,352 KB
testcase_20 AC 13 ms
4,352 KB
testcase_21 AC 14 ms
4,348 KB
testcase_22 AC 16 ms
4,356 KB
testcase_23 AC 26 ms
4,352 KB
testcase_24 AC 1 ms
4,352 KB
testcase_25 AC 2 ms
4,352 KB
testcase_26 AC 2 ms
4,352 KB
testcase_27 AC 2 ms
4,352 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,352 KB
testcase_30 AC 2 ms
4,352 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 1 ms
4,348 KB
testcase_33 AC 2 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> N;
	vector<long long>dp(N + 1);
	string s;
	cin >> s;
	dp[0] = 1;
	int c = 0;
	for (auto i : s) {
		vector<long long>nx(N + 1);
		int add = 1;
		if (i == ')')add = -1;
		c += add;
		for (int j = 0; j <= N; j++) {
			{
				int k = j + add;
				if (0 <= k && k <= c) {
					nx[k] += dp[j];
					nx[k] %= MOD;
				}
			}
			{
				int k = j;
				if (0 <= k && k <= c) {
					nx[k] += dp[j];
					nx[k] %= MOD;
				}
			}
		}
		dp = nx;
	}
	cout << dp[0] << endl;
}
0