#P16107. [ICPC 2019 NAIPC] XOR Sequences

[ICPC 2019 NAIPC] XOR Sequences

题目描述

Suppose you are given two integers, mm and nn. You are also given a list of nn distinct integers x1,x2,,xnx_1, x_2, \dots, x_n, with 0xi2m10 \leq x_i \leq 2^m - 1. For each number yy from 00 to 2m12^m - 1, you’ve found the number pyp_y such that xpyx_{p_y} has a maximum bitwise-XORXOR with yy. That is, yxpy>yxiy \oplus x_{p_y} > y \oplus x_i for all i=1..ni = 1..n, ipyi \ne p_y (\oplus means bitwise-XORXOR).

Now, consider the reverse problem. Given mm, nn, and the sequence p0,p1,,p2m1p_0, p_1, \dots, p_{2^m - 1}, count the number of sequences of distinct integers x1,x2,,xnx_1, x_2, \dots, x_n that could have generated that pp sequence from the above algorithm. Two xx sequences are different if there is some ii such that xix_i in one sequence is different from xix_i in the other sequence. Output this count modulo 109+710^9 + 7.

输入格式

Each test case will begin with a line with two space-separated integers mm (0m160 \leq m \leq 16) and nn (1n2m1 \leq n \leq 2^m), where 2m2^m is the length of the pp sequence, and nn is the length of the xx sequences.

Each of the next 2m2^m lines will contain a single integer pp (1pn1 \leq p \leq n). These are the values of the sequence p0,p1,,p2m1p_0, p_1, \dots, p_{2^m - 1}, in order. Every value from 11 to nn inclusive will appear at least once.

输出格式

Output a single integer, which is the number of sequences x1,x2,,xnx_1, x_2, \dots, x_n which could have generated the sequence p0,p1,,p2m1p_0, p_1, \dots, p_{2^m - 1} from the above algorithm, modulo 109+710^9 + 7.

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