結果
| 問題 |
No.2031 Colored Brackets
|
| コンテスト | |
| ユーザー |
SidewaysOwl
|
| 提出日時 | 2022-08-06 10:33:42 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 103 ms / 2,000 ms |
| コード長 | 645 bytes |
| コンパイル時間 | 167 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 76,416 KB |
| 最終ジャッジ日時 | 2024-09-16 06:23:29 |
| 合計ジャッジ時間 | 3,488 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
n = int(input())
s = list(input())
dp = [0]*(n//2+1)
ans = 1
dp[0] = 1
cnt = 0
mod = 998244353
for ii,e in enumerate(s):
n_dp = [0]*(n//2+1)
if e == "(":
cnt += 1
for i in range(n//2+1):
n_dp[i] += dp[i]
n_dp[i] %=mod
if i < n//2:
n_dp[i+1] += dp[i]
n_dp[i+1] %=mod
else:
cnt -= 1
for i in range(n//2+1):
if i <= cnt:
n_dp[i] += dp[i]
n_dp[i] %= mod
if i > 0:
n_dp[i-1] += dp[i]
n_dp[i-1] %= mod
dp = n_dp
# print(dp)
print(dp[0]%mod)
SidewaysOwl