atcoder#ARC139E. [ARC139E] Wazir
[ARC139E] Wazir
Score : points
Problem Statement
We have a grid with rows and columns. Let denote the square at the -th row from the top and -th column from the left. Assume that this grid is a torus; that is, in addition to the pairs of squares horizontally or vertically adjacent to each other, assume the following pairs of squares to be adjacent to each other.
- and , for every integer such that .
- and , for every integer such that .
Consider placing some number of pieces on the squares in the grid. Here, there can be at most one piece on each square, and there cannot be two pieces on adjacent squares. Let be the maximum number of pieces that can be placed. Find the number of ways, modulo , to place pieces.
Constraints
- and are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
3 2
6
The following six placements satisfy the condition. Here, #
and .
represent a square with and without a piece, respectively.
#. #. .# .# .. ..
.# .. #. .. #. .#
.. .# .. #. .# #.
139 424
148734121
12345 1234567890
227996418