Logo
(追記) (追記ここまで)

22531번 - Carpenters' Language 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB35262074.074%

문제

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:

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.

Alex's request is as follows: You have an empty string S in the beginning, and construct longer string by inserting a sequence of '(' or ')' into the string. You will receive $q$ queries, each of which consists of three elements $(p, c, n),ドル where $p$ is the position to insert, $n$ is the number of characters to insert and $c$ is either '(' or ')', the character to insert. For each query, your program should insert $c$ repeated by $n$ times into the $p$-th position of S from the beginning. Also it should output, after performing each insert operation, "Yes" if S is in the language and "No" if S is not in the language.

Please help Alex to support his study, otherwise he will fail to graduate the college.

입력

The first line contains one integer $q$ (1ドル \leq q \leq 10^5$) indicating the number of queries, follows $q$ lines of three elements, $p_i,ドル $c_i,ドル $n_i,ドル separated by a single space (1ドル \leq i \leq q,ドル $c_i = '(' or ')',ドル 0ドル \leq p_i \leq $ length of S before $i$-th query, 1ドル \leq n \leq 2^{20}$). It is guaranteed that all the queries in the input are valid.

출력

For each query, output "Yes" if S is in the language and "No" if S is not in the language.

제한

예제 입력 1

3
0 ( 10
10 ) 5
10 ) 5 

예제 출력 1

No
No
Yes

예제 입력 2

3
0 ) 10
10 ( 5
10 ( 5

예제 출력 2

No
No
Yes

예제 입력 3

3
0 ( 10
10 ) 20
0 ( 10

예제 출력 3

No
No
Yes

힌트

출처

Contest > ICPC Japanese Alumni Group > JAG Winter Contest > JAG Winter Contest 2012 A번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /