#P17207. 「DLESS-6」溶化
「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 and five sets consisting of integers in .
For two non-negative integers , define , i.e., the -th bit of in binary from low to high.
For a set consisting of non-negative integers, define a 5-tuple to be fair for if and only if:
- , , , , ;
- For every , in , the counts of and differ by at most .
For all , compute the number of 5-tuples that are fair for . Output the answer modulo the given positive integer .
Input Format
The first line contains two positive integers , representing the value range of the numbers and the modulus for the answers.
The next five lines each describe a set using characters from 01. If the -th character is 1, then is in the set; otherwise, is not in the set. The five sets described are , respectively.
Output Format
Output lines, each containing one non-negative integer. Line gives the answer for the set .
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 , the three 5-tuples that are fair for are: , , .
[Constraints]
For all testdata, , .
This problem uses bundled testcases. There are subtasks, each worth points. Subtask satisfies .
Translated by ChatGPT 5