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}]$ は「良い」配列ですか?

入力

入力の最初の行には、2つの整数 $n, q$ ($1 \le n \le 10^5, 1 \le q \le 10^5$) が含まれます。これらは配列の長さとクエリの数を表します。

2行目には、$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$) が含まれ、各クエリを表します。

出力

各クエリに対し、対応する部分配列が「良い」場合は 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.