1941 合法范式


Submit solution

Points: 100
Time limit: 1.0s
Memory limit: 32M

Problem types
Allowed languages
C, C++, Java, Python

Description

范式是只包含字符'(',')','{', '}','['和']'的字串。范式中只有当'('和')','{'和'}','['和']'三种括号都匹配(左右对应)时,才是合法的。显然,匹配须按正确的次序,例如范式”[]{()}”是合法的,而”[]{(})”则是非法的。现在需要判断一些范式是否合法。

Input

若干范式,中间没有空格,长度不超过60。

Output

对于每个范式,判断是否合法。若合法则输出“YES”,否则输出“NO”。

Sample

Input

[()]{}
(())[
(()[])
(({)})
(((){}))

Output

YES
NO
YES
NO
YES

Source: yz


Comments

There are no comments at the moment.