Typo
의견: 0
Bessie has just purchased a new laptop computer, but she unfortunately finds herself unable to type well, given the size of her large hooves relative to the small keyboard. Bessie has just attempted to type in one of her favorite patterns -- a balanced string of parentheses. However, she realizes that she might have mis-typed one character, accidentally replacing ( with ) or vice versa. Please help Bessie compute the number of locations in the string such that reversing the single parenthesis at that location would cause the entire string to become balanced.
A string of parentheses is "balanced" if there are the same total number of ('s and )'s, and for any prefix of the string there are at least as many ('s as )'s.
Line 1: A string of parentheses of length N (1 <= N <= 100,000).
The number of positions within the input string (if any) such that reversing the parenthesis at that single position would cause the entire string to become balanced.
typo.intypo.out()(())))4Output details: Reversing the parenthesis at position 2, 5, 6, or 7 results in a balanced string.
riseoj 작성
출처 올림피아드 > USACO > 2012-2013 > November > Bronze
평가 및 의견
Typo
Log in to rate problems.
아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.
풀이 제출
Typo