QOJ.ac

QOJ

Time Limit: 4 s Memory Limit: 512 MB Total points: 100

#7452. rupq

統計

给定一个长为 $n$ 的括号序列,每个位置有一个括号 $a_i$,其中 $a_i=1$ 代表是左括号 $'('$,$a_i=0$ 代表是右括号 $')'$。 $a_i$ 位置的括号有一个权值 $b_i$。

对任意括号序列,通过不断删除形如 $'()'$ 的子段直到无法操作,最终可以得到一个唯一的序列,这个序列称为不匹配括号,如 $a_1=')',a_2='(',a_3='(',a_4=')',a_5='('$,这个括号序列的不匹配括号序列为 $')(('$,其不匹配括号对应位置为 $1,2,5$,其不匹配括号对应位置的 $b$ 为 $b_1,b_2,b_5$。

有 $m$ 次操作,操作有以下三类:

1 x y:进行单点修改,即 $a_x:=1-a_x; b_x:=y$。

2 l r:求 $a[l..r]$ 中不匹配括号对应位置的 $b$ 从左到右的 $\texttt {NAND}$ ($32$ 位的按位与非,可以见 https://en.wikipedia.org/wiki/NAND_logic ), $\texttt {max}$(最大值) ,将二者 $\texttt {xor}$ 后输出。如果不匹配括号为空序列,则 $\texttt {NAND}$ 的答案为 $2^{32}-1$, $\texttt {max}$ 的答案为 $0$。

$\texttt {NAND}$ 即以 $c_0=2^{32}-1$ 为初值,然后依次 $c_i=\texttt {NAND}(c_{i-1},b_i)$,对于一个 $n$ 个值的序列 $b$,最后答案为 $c_n$。

3 l r:将 $a[l..r]$ 和 $a[r+1..n]$ 交换位置,$b$ 也做同样的操作。

输入格式

第一行用空格隔开的两个数 $n,m$。

之后 $n$ 行每行用空格隔开的两个数,第 $i$ 行为 $a_i,b_i$。

之后 $m$ 行,每行表示一个操作。

输出格式

对每个操作 $2$ 输出一行表示答案。

样例数据

样例输入

10 10
0 1
1 9
1 2
0 5
1 1
0 6
1 1
0 4
0 8
1 7
2 5 7
3 1 10
1 1 3
2 1 3
3 2 9
3 4 10
3 7 8
1 10 2
3 3 4
2 5 7

样例输出

4294967295
4294967284
4294967281

子任务

Idea:ccz181078,Solution:ccz181078,Code:ccz181078,Data:nzhtl1477

对于 $100\%$ 的数据,

$0 \le a[i] \le 1$。

$0 \le b[i] \le 10^9$。

$1 \le n \le 2\times10^6,1 \le m \le 2\times10^5$。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.