QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 1024 MB مجموع النقاط: 100

#3013. 异或序列

الإحصائيات

给定两个整数 $m$ 和 $n$。同时给定一个包含 $n$ 个不同整数的序列 $x_1, x_2, \cdots, x_n$,其中 $0 \leq x_i \leq 2^m-1$。对于 $0$ 到 $2^m-1$ 之间的每个数 $y$,你已经找到了一个数 $p_y$,使得 $x_{p_y}$ 与 $y$ 的按位异或值最大。即对于所有 $i = 1, \cdots, n, i \neq p_y$,都有 $y \oplus x_{p_y} > y \oplus x_i$(其中 $\oplus$ 表示按位异或)。

现在,考虑反向问题。给定 $m, n$ 以及序列 $p_0, p_1, \cdots, p_{2^m-1}$,计算有多少种不同的整数序列 $x_1, x_2, \cdots, x_n$ 可以通过上述算法生成该 $p$ 序列。如果两个 $x$ 序列中存在某个 $i$ 使得 $x_i$ 不同,则认为这两个 $x$ 序列是不同的。输出该计数对 $10^9+7$ 取模的结果。

输入格式

每个测试用例的第一行包含两个空格分隔的整数 $m$ ($0 \leq m \leq 16$) 和 $n$ ($1 \leq n \leq 2^m$),其中 $2^m$ 是 $p$ 序列的长度,$n$ 是 $x$ 序列的长度。

接下来的 $2^m$ 行,每行包含一个整数 $p$ ($1 \leq p \leq n$)。这些是序列 $p_0, p_1, \dots, p_{2^m-1}$ 的值,按顺序排列。从 $1$ 到 $n$ 的每个值至少会出现一次。

输出格式

输出一个整数,表示可以生成序列 $p_0, p_1, \cdots, p_{2^m-1}$ 的序列 $x_1, x_2, \cdots, x_n$ 的数量,对 $10^9+7$ 取模。

样例

样例输入 1

3 6
1
1
2
2
3
4
5
6

样例输出 1

4

样例输入 2

2 3
1
2
1
3

样例输出 2

0

样例输入 3

3 8
1
2
3
4
5
6
7
8

样例输出 3

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.