QOJ.ac

QOJ

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

#1650. AND = OR

Estadísticas

Một mảng các số nguyên $[b_1, b_2, \dots, b_m]$ được gọi là tốt nếu ta có thể chia tất cả các phần tử của nó thành 2 nhóm không rỗng, sao cho kết quả phép toán bitwise AND của các phần tử trong nhóm thứ nhất bằng kết quả phép toán bitwise OR của các phần tử trong nhóm thứ hai. Ví dụ, mảng $[1, 7, 3, 11]$ là tốt vì ta có thể chia nó thành $[1, 3]$ và $[7, 11]$, trong đó $1 \text{ OR } 3 = 3$ và $7 \text{ AND } 11 = 3$.

Cho một mảng $[a_1, a_2, \dots, a_n]$, bạn cần trả lời $q$ truy vấn dạng: mảng con $[a_{l_i}, a_{l_i+1}, \dots, a_{r_i}]$ có phải là mảng tốt hay không?

Dữ liệu vào

Dòng đầu tiên của dữ liệu vào chứa hai số nguyên $n, q$ ($1 \le n \le 10^5, 1 \le q \le 10^5$) — độ dài của mảng và số lượng truy vấn tương ứng.

Dòng thứ hai chứa $n$ số nguyên $a_1, a_2, \dots, a_n$ ($0 \le a_i \le 2^{30} - 1$) — các phần tử của mảng.

Dòng thứ $i$ trong $q$ dòng tiếp theo chứa 2 số nguyên $l_i, r_i$ ($1 \le l_i \le r_i \le n$) — mô tả truy vấn thứ $i$.

Dữ liệu ra

Với mỗi truy vấn, in ra YES nếu mảng con tương ứng là tốt, và NO nếu không phải.

Ví dụ

Dữ liệu vào 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

Dữ liệu ra 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.