#P8933. [JRKSJ R7] 技巧性的块速递推
[JRKSJ R7] 技巧性的块速递推
Background
Sufficient and necessary, Chebyshev.
Originally yes, but no longer needed.
Problem Description
Given an chessboard, color each cell with one of two colors: black or white.
Count how many colorings satisfy both of the following:
- Among any 4 consecutive cells in a horizontal, vertical, or diagonal line, there do not exist at least 3 cells with the same color.
- Among any 3 consecutive cells in a horizontal, vertical, or diagonal line, the colors are not all the same.
Let the top-left corner be and the bottom-right corner be . Then:
- is a set of 3 consecutive horizontal cells.
- is a set of 3 consecutive vertical cells.
- and are sets of 3 consecutive diagonal cells.
All the above cells must lie inside the board.
The definition for 4 consecutive cells is analogous.
Input Format
This problem has multiple test cases.
The first line contains an integer , the number of test cases.
The next lines each contain two integers , representing one query.
Output Format
Output lines, each containing one integer: the answer. Take the answer modulo .
1
2 2
16
1
3 3
32
Hint
Sample Explanation
Sample : Clearly, any coloring is valid, so the answer is .
Sample :
101
110
010
This is one valid coloring.
111
110
011
This is one invalid coloring, because , , and all do not satisfy the conditions.
Constraints
This problem uses bundled testdata.
For of the testdata, , .
Translated by ChatGPT 5