Lyndon's Golf Contest 1 P8 - Beautiful Brackets

View as PDF

Submit solution


Points: 0 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
C, C++

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 s (1 \le |s| \le 100).

Output Specification

Output YES if s 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 L-byte program,

  • if L \le 68, you will receive the full 100 points.
  • if 69 \le L, you will recieve \lfloor 2^{0.105(130-n)} \rfloor points.

Sample Input 1

(((())))

Sample Output 1

YES

Sample Input 2

(()())

Sample Output 2

NO

Comments

There are no comments at the moment.