Wednesday, November 26, 2008

ACM ICPC Philippines 2008: Problem B

.
2nd Philippine National Inter-Collegiate Programming Competition
(ACM Philippines 2008)
22 November 2008, Cebu City

Problem B: “Balanced Parentheses”
Input File: b.in


Check if a sequence of parentheses is balanced or not. An open parenthesis should match with the nearest close parenthesis.

If balanced, output the sequence as is, otherwise, replace the unbalanced parentheses with square brackets.


Sample Input / Sample Output

(((()))) / Case 1: (((())))
((()))) / Case 2: ((()))]
((()(()) / Case 3: [[()(())
()())(() / Case 4: ()()][()

-------------------------------------------------------

Problem Category: Easy

Number of teams which solved this problem: 24 (out 39)

Success rate: 80 %

For more information, contact: computingsoc@gmail.com

.

No comments: