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]$의 모든 원소를 2개의 비어 있지 않은 그룹으로 나누었을 때, 첫 번째 그룹 원소들의 비트 단위 AND 값이 두 번째 그룹 원소들의 비트 단위 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$개의 줄에는 각각 2개의 정수 $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.