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

16815번 - Star in Parentheses 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB55139330072.639%

문제

You are given a string $S,ドル which is balanced parentheses with a star symbol * inserted.

Any balanced parentheses can be constructed using the following rules:

  • An empty string is balanced.
  • Concatenation of two balanced parentheses is balanced.
  • If $T$ is balanced parentheses, concatenation of (, $T,ドル and ) in this order is balanced.

For example, ()() and (()()) are balanced parentheses. )( and )()(() are not balanced parentheses.

Your task is to count how many matching pairs of parentheses surround the star.

Let $S_i$ be the $i$-th character of a string $S$. The pair of $S_l$ and $S_r$ $(l < r)$ is called a matching pair of parentheses if $S_l$ is (, $S_r$ is ) and the surrounded string by them is balanced when ignoring a star symbol.

입력

The input consists of a single test case formatted as follows.

$S$

$S$ is balanced parentheses with exactly one * inserted somewhere. The length of $S$ is between 1ドル$ and 100ドル,ドル inclusive.

출력

Print the answer in one line.

제한

예제 입력 1

((*)())

예제 출력 1

2

예제 입력 2

(*)

예제 출력 2

1

예제 입력 3

(()())*

예제 출력 3

0

예제 입력 4

()*()

예제 출력 4

0

예제 입력 5

((((((((((*))))))))))

예제 출력 5

10

예제 입력 6

*

예제 출력 6

0

힌트

출처

Contest > ICPC Japanese Alumni Group > JAG Summer Camp > JAG Summer Camp 2017 Day 3 A번

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

출처

대학교 대회

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

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