QOJ.ac

QOJ

Límite de tiempo: 2.0 s Límite de memoria: 256 MB Puntuación total: 100 Hackeable ✓

#9669. 函数查询

Estadísticas

给定 $n$ 个整数 $x_1, x_2, \dots, x_n$。现有 $q$ 次查询,每次查询给出一个函数 $f(x) = (a \oplus x) - b$,请判断是否存在 $1 \le i < n$ 使得 $f(x_i) \cdot f(x_{i+1}) \le 0$。如果存在,输出满足条件的 $i$;否则输出 $-1$。

$a \oplus b$ 表示 $a$ 和 $b$ 的按位异或运算。

输入格式

第一行包含两个整数 $n, q$ ($2 \le n \le 3 \cdot 10^5$, $1 \le q \le 3 \cdot 10^5$)。

第二行包含 $n$ 个整数 $x_1, x_2, \dots, x_n$ ($0 \le x_i \le 10^9$)。

接下来 $q$ 行,每行包含两个整数 $a, b$ ($0 \le a, b \le 10^9$)。

输出格式

输出 $q$ 行,表示每次查询的答案。

样例

样例输入 1

5 6
3 5 1 2 4
0 2
1 1
2 3
3 2
4 2
5 8

样例输出 1

2
3
2
1
4
-1

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.