CT24579

Devi's Scarlet riddles

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Legend says the vault under the cliffside roost of Stormrest opens only for a perfect tally of riddles. Devi means to find out. Task: A string contains only '(' and ')'. Print YES if it is a balanced bracket sequence, otherwise NO. Input format: One line with a string of parentheses. Output format: Print YES or NO. Constraints: 1 <= |s| <= 1658; characters are '(' and ')'.

Example 1:

Input: ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
Output: YES

Example 2:

Input: ))(())))())()(()))()(()()((())((()(()()))()((()((((())(((((()))(()()(())((((((())()))))(((((())(()))))))))()(()(()))())()))()(((()(()()((())))()()(()()()())))(()())))((((((()))(()(((((((()((())))()))))(())))())())())())))(()()()(())())))(())(()()((()(())))))((()())(()()(())((()))(())))))((())))())))())((())(()())))((())())()((()((((((()())())())((()(()))((()))(())())())(())()(()(())))(()(())(()))()))))()()(()((())()()))((()()(())))((((())))())()())(()(()()(((())(()()((((())())))())(()))((())()()()((()()))())()))()(((()()()())()()))(()((())())))())()(()())(((()((((()()()(((())((()))(((()())())))()))()))()((()))())))()())))(())((()(()))())())))())((((((((()))(())))))()(((()())((()))((()(((())))((()()())(((((()(()))((())))((()))(()))))((())()(())()()((()((()(())()())(()()))((())
Output: NO

Example 3:

Input: )))))()(()))(((()((())))())()()()))(())))()()(((()))()()))((())()())(()))()((())())))(())))(()((()))()(())(()(()())))((()())()(((()())(()))()))(())))()()(()(())))))(((()()()(())))()())())))))(())()))()(())((()()())())())()()()))(())(())()))()((()()))(()))(())))()()((()((()()))((()))))))())))))(()))()()))()())(((((())((())))))()())())((())((()()()(())(((()(())))))())()())((()))()(()(()((()))(()))()()()(()(()((()()((()())())))()()))))(()()))))()((()(())))()(((()))(())((()(()((()()((((()(()))))(((())((((()))))(((()((((())((()()()(())())()))(((()())))))))(()(())))()((((()(())(((()(((()()))())((()()())
Output: NO

Constraints:

1 <= |s| <= 1658; characters are '(' and ')'.

Loading...
Test Cases:No test cases
No test cases available.