| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1.5 초 (추가 시간 없음) | 1024 MB | 76 | 34 | 32 | 51.613% |
You are given a bracket sequence consisting of $N$ open brackets and $N$ closed brackets. Let $S$ be a nonempty set of integers between $1$ and $2N$, inclusively. You can choose two indices in $S$, not necessarily adjacent, and swap the brackets of the bracket sequence at those two positions.
Find the number of $S$ that can result in a proper bracket sequence by repeatedly applying this operation arbitrary number of times.
The first line contains one integer $N$.
The second line contains a string of $2N$ brackets, either ( or ).
Print the number of all possible $S$ in modulo $998\, 244\, 353$. $998\, 244\, 353$ is a prime number.
3 ())(()
36
6 ()))(())()((
1536