题库练习 Bitwise Paradox
← 上一题 下一题 →

A11279 | Bitwise Paradox

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

You are given two arrays $a$ and $b$ of size $n$ along with a fixed integer $v$ .

An interval $[l, r]$ is called a good interval if $(b_l \mid b_{l+1} \mid \ldots \mid b_r) \ge v$ , where $|$ denotes the [bitwise OR operation](https://en.wikipedia.org/wiki/Bitwise_operation#OR). The beauty of a good interval is defined as $\max(a_l, a_{l+1}, \ldots, a_r)$ .

You are given $q$ queries of two types:

- "1 i x": assign $b_i := x$ ;
- "2 l r": find the minimum beauty among all good intervals $[l_0,r_0]$ satisfying $l \le l_0 \le r_0 \le r$ . If there is no suitable good interval, output $-1$ instead.

Please process all queries.

输入格式

Each test contains multiple test cases. The first line contains the number of test cases $t$ ( $1 \le t \le 10^5$ ). The description of the test cases follows.

The first line of each test case contains two integers $n$ and $v$ ( $1 \le n \le 2 \cdot 10^5$ , $1 \le v \le 10^9$ ).

The second line of each testcase contains $n$ integers $a_1, a_2, \ldots, a_n$ ( $1 \le a_i \le 10^9$ ).

The third line of each testcase contains $n$ integers $b_1, b_2, \ldots, b_n$ ( $1 \le b_i \le 10^9$ ).

The fourth line of each testcase contains one integer $q$ ( $1 \le q \le 2 \cdot 10^5$ ).

The $i$ -th of the following $q$ lines contains the description of queries. Each line is of one of two types:

- "1 i x" ( $1 \le i \le n$ , $1 \le x \le 10^9)$ ;
- "2 l r" ( $1 \le l \le r \le n$ ).

It is guaranteed that both the sum of $n$ and the sum of $q$ over all test cases do not exceed $2 \cdot 10^5$ .

输出格式

For each test case, output the answers for all queries of the second type.

输入输出样例

输入 #1
3
3 7
2 1 3
2 2 3
4
2 1 3
1 2 5
2 2 3
2 1 3
4 5
5 1 2 4
4 2 3 3
6
2 1 4
1 3 15
2 3 4
2 2 4
1 2 13
2 1 4
1 5
6
4
1
2 1 1
输出 #1
-1 3 2 
5 2 2 1 
-1
C++ 编辑器
输入
输出