300854: CF162J. Brackets

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Brackets

题意翻译

## 题目描述 一个由括号组成的序列被称作**平衡的**,当且仅当这个序列可以通过在字符串中加入“+”号或数字 $1$。例如,序列"(())()", "()" 和 "(()(()))"是**平衡的**,但是")(", "(()" 和 "(()))(" 不是平衡的。 给定一个由左右圆括号组成的字符串,请你判断它是否是**平衡的**。 ## 输入格式 输入的第一行包含一个长度在$1$到$100$之间的字符串(包含1和100)。字符串中的每个字符只有可能是"("或者")"。 ## 输出格式 如果这个括号序列是平衡的,输出"YES",否则输出"NO"。(不含引号) 翻译By @若如初见

题目描述

A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters "+" and "1". For example, sequences "(())()", "()" and "(()(()))" are balanced, while ")(", "(()" and "(()))(" are not. You are given a string which consists of opening and closing round brackets. Check whether it is a balanced bracket sequence.

输入输出格式

输入格式


The only line of input contains a string between $ 1 $ and $ 100 $ characters long, inclusive. Each character in the string will be "(" or ")".

输出格式


Output "YES" if the bracket sequence is balanced, and "NO" otherwise (quotes for clarity only).

输入输出样例

输入样例 #1

(()(()))()

输出样例 #1

YES

输入样例 #2

())()

输出样例 #2

NO

Input

题意翻译

## 题目描述 一个由括号组成的序列被称作**平衡的**,当且仅当这个序列可以通过在字符串中加入“+”号或数字 $1$。例如,序列"(())()", "()" 和 "(()(()))"是**平衡的**,但是")(", "(()" 和 "(()))(" 不是平衡的。 给定一个由左右圆括号组成的字符串,请你判断它是否是**平衡的**。 ## 输入格式 输入的第一行包含一个长度在$1$到$100$之间的字符串(包含1和100)。字符串中的每个字符只有可能是"("或者")"。 ## 输出格式 如果这个括号序列是平衡的,输出"YES",否则输出"NO"。(不含引号) 翻译By @若如初见

加入题单

算法标签: