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

24582번 - Bracket Pairing 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
7 초 (추가 시간 없음) 1024 MB47232150.000%

문제

There are four types of brackets: round (), square [], curly {}, and angle <>. A bracket sequence is defined to be valid as follows:

  • An empty sequence is valid.
  • If X is a valid bracket sequence, then pXq is a valid bracket sequence, where p is an open bracket, q is a close bracket, and p, q are of the same type.
  • If X and Y are valid bracket sequences, then the concatenation of X and Y , Z = XY , is a valid bracket sequence.

You have a bracket sequence in which some brackets are given, but the others are unknown and represented by question marks (‘?’). You shall fill in each unknown bracket using the four types of brackets described above and obtain a valid bracket sequence. How many different valid bracket sequences can you obtain?

입력

The input has a single line giving a non-empty bracket sequence. The length of the sequence is even and no larger than 20. All sequence characters are either one of the four types of open or close brackets, or a question mark denoting an unknown bracket. There is at least one question mark in the sequence.

출력

Output the number of different valid bracket sequences you can obtain.

제한

예제 입력 1

(??)

예제 출력 1

5

예제 입력 2

(<{}>??]

예제 출력 2

1

예제 입력 3

(?]]

예제 출력 3

0

힌트

출처

ICPC > Regionals > North America > Mid-Atlantic Regional > 2021 Mid-Atlantic USA Regional Contest F번

ICPC > Regionals > North America > North Central North America Regional > 2021 North Central NA Regional Contest K번

  • 문제를 만든 사람: Bowen Yu
(追記) (追記ここまで)

출처

대학교 대회

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

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