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

21884번 - Boolean Expression 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 512 MB46251346.429%

문제

You are given a boolean expression, consisting of <<0>>, <<1>>, operations <<&>> (boolean "AND"), <<|>> (boolean "OR"), <<^>> (<<XOR>>, boolean "exclusive OR"), and parentheses. A correct boolean expression can be defined recursively: an expression is correct, if it is either equal to one character <<0>> or <<1>>, or it is an application of some boolean operation to two correct boolean expressions. For simplicity, every application of a boolean operation is put into parentheses. The given expression does not contain spaces or any other characters except the ones described above. For instance, <<((0|1)|0)>>, <<(0&1)>> and <<0>> are correct expressions, and <<0|1>>, <<0|1&1>> and <<(0)>> are not.

Calculate the result of this expression. By the way, the expression is changing! You are also given $m$ queries to change a character at some position. Calculate the value of the given expression after each query.

입력

First line contains string $S,ドル a correct boolean expression with at most 800ドル,000円$ characters.

Next line contains a single integer $m$ (1ドル \le m \le 400,000円$) --- number of queries. Then, $m$ lines follow. Each line contains an integer and a character $p_i$ $c_i$, meaning that you should change a character at position $p_i$ to $c_i$. It's guaranteed that the expression remains correct after every query.

출력

Output $m+1$ characters <<0>> or <<1>> on a single line. First character should be equal to the value of the original expression. Next $m$ characters should be equal to the value of the expression after each query.

제한

서브태스크

번호배점제한
110

$|S| \le 5,ドル $m \le 10$

210

$|S| \le 200,ドル $m \le 200$

320

$|S| \le 2,000円,ドル $m \le 2,000円$

425

$|S| \le 200,000円,ドル $m \le 100,000円$

535

$|S| \le 800,000円,ドル $m \le 400,000円$

예제 입력 1

((1&1)^(0|1))
3
11 0
7 |
5 0

예제 출력 1

0110

힌트

출처

Contest > Innopolis Open in Informatics > Innopolis Open, Second elimination round, 2018-2019 E번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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