Everyone knows that bracket matching problems are the best types of problems. Today, you will be examining some especially beautiful brackets!
A bracket sequence is a string consisting solely of (
s and )
s. A beautiful bracket sequence is a bracket sequence that contains an equal number of (
s and )
s, and whose last occurrence of (
comes before the first occurrence of )
. For example, ()
, (())
, and ((((()))))
are beautiful, whereas ())
, ((())
, and ()()()
are not.
Given a bracket sequence, your task is to determine whether it is beautiful or not.
Note: You may only submit to this problem in C/C++.
Input Specification
The first line of input contains a single string .
Output Specification
Output YES
if is a beautiful bracket sequence, and NO
otherwise.
Scoring
Your score will be computed based on the length of your source code, the shorter the better. For an -byte program,
- if , you will receive the full 100 points.
- if , you will recieve points.
Sample Input 1
(((())))
Sample Output 1
YES
Sample Input 2
(()())
Sample Output 2
NO
Comments