QOJ.ac

QOJ

Límite de tiempo: 3 s Límite de memoria: 1024 MB Puntuación total: 100

#1650. AND = OR

Estadísticas

如果一个整数数组 $[b_1, b_2, \dots, b_m]$ 可以被划分为两个非空组,使得第一组中所有元素的按位与(bitwise AND)等于第二组中所有元素的按位或(bitwise OR),则称该数组是“好的”(good)。例如,数组 $[1, 7, 3, 11]$ 是好的,因为我们可以将其划分为 $[1, 3]$ 和 $[7, 11]$,其中 $1 \text{ OR } 3 = 3$ 且 $7 \text{ AND } 11 = 3$。

给定一个数组 $[a_1, a_2, \dots, a_n]$,你需要回答 $q$ 个询问,每个询问的形式为:子数组 $[a_l, a_{l+1}, \dots, a_r]$ 是否是好的?

输入格式

第一行包含两个整数 $n, q$ ($1 \le n \le 10^5, 1 \le q \le 10^5$),分别表示数组的长度和询问的次数。

第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($0 \le a_i \le 2^{30} - 1$),表示数组的元素。

接下来的 $q$ 行中,第 $i$ 行包含两个整数 $l_i, r_i$ ($1 \le l_i \le r_i \le n$),描述第 $i$ 个询问。

输出格式

对于每个询问,如果对应的子数组是好的,输出 YES,否则输出 NO。

样例

样例输入 1

5 15
0 1 1 3 2
1 1
1 2
1 3
1 4
1 5
2 2
2 3
2 4
2 5
3 3
3 4
3 5
4 4
4 5
5 5

样例输出 1

NO
NO
YES
YES
YES
NO
YES
YES
YES
NO
NO
YES
NO
NO
NO

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#311EditorialOpen题解jiangly2025-12-14 07:02:29View

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.