QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 1024 MB Total points: 100 Hackable ✓

#7411. 按位异或

Statistics

Zhong Ziqian 收到了一份包含整数数组 $a_1, a_2, \dots, a_n$ 和一个整数 $x$ 的生日礼物。

此后,他每天都会尝试寻找该数组的一个非空子序列 $1 \le b_1 < b_2 < \dots < b_k \le n$,使得对于所有满足 $1 \le i < j \le k$ 的数对 $(i, j)$,不等式 $a_{b_i} \oplus a_{b_j} \ge x$ 均成立。其中 $\oplus$ 表示按位异或运算。

当然,他每天都必须找到一个不同的子序列。

他最多能坚持多少天而不重复?由于这个数字可能非常大,请输出其对 $998\,244\,353$ 取模的结果。

输入格式

第一行包含两个整数 $n$ 和 $x$ ($1 \le n \le 300\,000$, $0 \le x \le 2^{60} - 1$)。其中 $n$ 是数组的大小。

第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$:数组本身 ($0 \le a_i \le 2^{60} - 1$)。

输出格式

输出一个整数:Ziqian 的数组中满足任意元素对的按位异或值至少为 $x$ 的子序列数量,对 $998\,244\,353$ 取模。

样例

样例输入 1

3 0
0 1 2

样例输出 1

7

样例输入 2

3 2
0 1 2

样例输出 2

5

样例输入 3

3 3
0 1 2

样例输出 3

4

样例输入 4

7 4
11 5 5 8 3 1 3

样例输出 4

35

说明

在第一个样例中,所有 $2^3 - 1$ 个非空子序列均符合条件。

在第二个样例中,有两个非空子序列不符合条件,即 $b = [1, 2]$ 和 $b = [1, 2, 3]$,这是因为 $a_1 \oplus a_2 = 0 \oplus 1 = 1$,小于 $2$。

在第三个样例中,$b = [1], b = [2], b = [3], b = [2, 3]$ 符合条件。

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.