By Neilor Tonin, URI Brazil
Considering an expression with parenthesis, print a message informing if the among of parenthesis is correct or incorrect, without considering the rest of the expression. Example:
when
(a*b-(2+c) is incorrect
2*(3-a)) is incorrect
)3+b*(2-c)( is incorrect
Resuming, all closing parenthesis must have an open parenthesis and it's not possible a closing parenthesis without a previous open parenthesis, and the quantity of closing and open parenthesis must be the same.
The input file contains N expressions (1 <= N <= 10000), each one with up to 1000 characters.
The output must be correct or incorrect for each test case according with above rules.
Input Sample | Output Sample |
a+(b*c)-2-a |
correct correct incorrect incorrect incorrect |