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]$ 可以被劃分為兩個非空群組,使得第一個群組中所有元素的位元 AND(bitwise AND)等於第二個群組中所有元素的位元 OR(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_i}, a_{l_i+1}, \dots, a_{r_i}]$ 是否為好的?

輸入格式

第一行包含兩個整數 $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.