eolymp
bolt
Try our new interface for solving problems
Problems

Carpenters` Language

Carpenters` Language

International Carpenters Professionals Company (ICPC) is a top construction company with a lot of expert carpenters. What makes ICPC a top company is their original language. The syntax of the language is simply given in CFG as follows: \textbf{S -> SS | (S) | )S( | ε} In other words, a right parenthesis can be closed by a left parenthesis and a left parenthesis can be closed by a right parenthesis in this language. Alex, a grad student mastering linguistics, decided to study ICPC's language. As a first step of the study, he needs to judge whether a text is well-formed in the language or not. Then, he asked you, a great programmer, to write a program for the judgement. c Alex's request is as follows: You have an empty string \textbf{S} in the beginning, and construct longer string by inserting a sequence of '\textbf{(}' or '\textbf{)}' into the string. You will receive \textbf{q} queries, each of which consists of three elements (\textbf{p}, \textbf{c}, \textbf{n}), where \textbf{p} is the position to insert, \textbf{n} is the number of characters to insert and \textbf{c} is either '\textbf{(}' or '\textbf{)}', the character to insert. For each query, your program should insert repeated by \textbf{n} times into the \textbf{p}-th position of \textbf{S} from the beginning. Also it should output, after performing each insert operation, "\textbf{Yes}" if \textbf{S} is in the language and "\textbf{No}" if \textbf{S} is not in the language. Please help Alex to support his study, otherwise he will fail to graduate the college. \InputFile The first line contains one integer \textbf{q} (\textbf{1} ≤ \textbf{q} ≤ \textbf{10^5}) indicating the number of queries, follows \textbf{q} lines of three elements, \textbf{p}, \textbf{c}, \textbf{n}, separated by a single space (\textbf{1} ≤ \textbf{i} ≤ \textbf{q}, \textbf{c_i} = '\textbf{(}' or '\textbf{)}', \textbf{0} ≤ \textbf{p_i} ≤ length of \textbf{S} before \textbf{i}-th query, \textbf{1} ≤ \textbf{n} ≤ \textbf{2^20}). It is guaranteed that all the queries in the input are valid. \OutputFile For each query, output "\textbf{Yes}" if \textbf{S} is in the language and "\textbf{No}" if \textbf{S} is not in the language.
Time limit 1 second
Memory limit 64 MiB
Input example #1
3
0 ( 10
10 ) 5
10 ) 5
Output example #1
No
No
Yes
Source Japan Alumni Group Winter Contest 2012