algorithm_2024/src/U206625/U206625.md
2024-10-06 22:57:41 +08:00

77 lines
1.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 括号序列问题1
## 题目描述
给一个长度为 $n$ 的括号串 $s$,其中连续的一段 $s[l...r]$ 称为 $s$ 的子串。
合法串的定义如下:
1. `()` 是合法括号串。
2. 如果 `A` 是合法括号串,则 `(A)` 是合法括号串。
3. 如果 `A``B` 是合法括号串,则 `AB` 是合法括号串。
对于串 $t$,其所有子串中合法串的数量记为 $f(t)$
求 $s$ 串所有子串的 $f$ 值之和,即 $\sum_{l\le r}f(s[l...r])$,模 998244353。
## 输入格式
一个字符串 $s$
## 输出格式
输出一个整数代表答案
## 样例 #1
### 样例输入 #1
```
())
```
### 样例输出 #1
```
2
```
## 样例 #2
### 样例输入 #2
```
(()()
```
### 样例输出 #2
```
12
```
## 样例 #3
### 样例输入 #3
```
)(()())()
```
### 样例输出 #3
```
66
```
## 提示
设 $n$ 为输入串长度:
子任务120分$1\le n\le 100$
子任务220分$1\le n\le 700$
子任务320分$1\le n\le 5000$
子任务440分$1\le n\le 300000$