#P17207. 「DLESS-6」溶化

    ID: 19721 远端评测题 3000ms 1024MiB 尝试: 0 已通过: 0 显示难度NOI/NOI+/CTS 上传者: 标签>数学快速沃尔什变换 FWT

「DLESS-6」溶化

Background

Now, even if I "melt" you, who was floating in the sky, into the air,
there is still a feeling that will not change.

Problem Description

You are given a positive integer nn and five sets A,B,C,D,EA, B, C, D, E consisting of integers in [0,2n)[0, 2^n).

For two non-negative integers x,ix, i, define xi=⌊x/2i⌋ mod 2x_i = \lfloor x / 2^i \rfloor \bmod 2, i.e., the (i+1)(i+1)-th bit of xx in binary from low to high.

For a set SS consisting of non-negative integers, define a 5-tuple (a,b,c,d,e)(a, b, c, d, e) to be fair for SS if and only if:

  • a∈Aa \in A, b∈Bb \in B, c∈Cc \in C, d∈Dd \in D, e∈Ee \in E;
  • For every i∈Si \in S, in [ai,bi,ci,di,ei][a_i, b_i, c_i, d_i, e_i], the counts of 00 and 11 differ by at most 11.

For all S⊆{0,1,⋯ ,n−1}S \subseteq \{0, 1, \cdots, n-1\}, compute the number of 5-tuples that are fair for SS. Output the answer modulo the given positive integer PP.

Input Format

The first line contains two positive integers n,Pn, P, representing the value range of the numbers and the modulus for the answers.

The next five lines each describe a set using 2n2^n characters from 01. If the ii-th character is 1, then i−1i - 1 is in the set; otherwise, i−1i - 1 is not in the set. The five sets described are A,B,C,D,EA, B, C, D, E, respectively.

Output Format

Output 2n2^n lines, each containing one non-negative integer. Line kk gives the answer for the set S={i∣(k−1)i=1}S = \{ i \mid (k - 1)_i = 1 \}.

2 1000000000
1000
0010
0101
1000
0101
4
4
3
3

2 1000000000
1110
0110
1101
1111
0101
144
92
88
57

3 1000000000
11101101
01011010
11001101
01110101
01101101
3000
1770
1812
1071
1890
1084
1141
652

4 1000000000
1110110111111111
1111110101010101
0110111011101111
0011110111001101
1001111111101101
221760
139104
132236
82818
137312
86926
82048
51869
140280
88038
83500
52354
86869
55043
51747
32767

Hint

[Sample #1 Explanation]

For S={0,1}S = \{0, 1\}, the three 5-tuples that are fair for SS are: (0,2,1,0,3)(0, 2, 1, 0, 3), (0,2,3,0,1)(0, 2, 3, 0, 1), (0,2,3,0,3)(0, 2, 3, 0, 3).

[Constraints]

For all testdata, 1≤n≤151 \le n \le 15, 108≤P≤10910^8 \le P \le 10^9.

This problem uses bundled testcases. There are 1010 subtasks, each worth 1010 points. Subtask ii satisfies n=i+5n = i + 5.

Translated by ChatGPT 5