Logo
(追記) (追記ここまで)

30302번 - Swapping Brackets 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1.5 초 (추가 시간 없음) 1024 MB76343251.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 2ドルN,ドル 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 2ドルN$ brackets, either ( or ).

출력

Print the number of all possible $S$ in modulo 998ドル,円 244,円 353$. 998ドル,円 244,円 353$ is a prime number.

제한

  • 1ドル\leq N\leq 3000$
  • Given bracket sequence contains $N$ open brackets and $N$ closed brackets.

예제 입력 1

3
())(()

예제 출력 1

36

예제 입력 2

6
()))(())()((

예제 출력 2

1536

힌트

출처

University > KAIST > KAIST ICPC Mock Competition > 2023 KAIST 13th ICPC Mock Competition K번

Camp > Petrozavodsk Programming Camp > Summer 2024 > Day 2: K-ontest M번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /