#P4262. [Code+#3] 白金元首与莫斯科
[Code+#3] 白金元首与莫斯科
Description
In an grid, there is an army unit that needs resupply. Each cell in the area is either an empty cell or an obstacle. The air fleet needs to dispatch several transport planes to this area. Each transport plane can drop supplies to two adjacent (sharing a common edge) empty cells. To prevent unnecessary damage, a cell marked as empty can receive at most one drop.
Due to the weather, the exact location of the army unit cannot be determined. Therefore, for every empty cell, when the army unit is in that cell (treat it as an obstacle), the Führer wants to know the number of different schemes to drop any amount of supplies to the remaining empty cells using any number (possibly ) of transport planes. Two schemes are different if and only if there exists a cell that is supplied in one scheme but not in the other, or there exist two supplied cells that are supplied by the same plane in one scheme but not so in the other. If you are still unsure, please refer to the explanation for Sample 1.
You need to write a program to compute these values.
Input Format
Line 1: two space-separated positive integers — the number of rows and columns of the grid region. Next lines: line contains space-separated integers — means the cell in row , column is an empty cell; means the cell is an obstacle.
Output Format
Output lines. Line contains space-separated integers — if the cell in row , column is an empty cell, then is the number of schemes after turning that cell into an obstacle; otherwise . Each answer is taken modulo .
2 4
0 0 0 0
0 0 0 1
14 13 10 22
15 11 17 0
4 5
0 0 0 1 1
1 0 0 0 1
1 0 0 0 0
0 0 0 0 0
1882 827 1523 0 0
0 1189 791 1529 0
0 1106 979 823 1315
1810 899 1136 1075 1189
Hint
Explanation for Sample 1
Take the empty cell in row , column as an example. After it is changed into an obstacle, the grid is as follows. Cells marked with o are empty, and cells marked with x are obstacles.
oooo
xoox
There are schemes as shown below. Different colors represent the drop positions of different transport planes.

Constraints
This problem uses bundled tests. The information for each test point is as follows: | Subtask ID | Points | | | | :----------: | :----------: | :----------: | :----------: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
For all testdata, , .
Notes
Von allem Anfang an bin ich nur verraten und betrogen worden!
The statement does not fully agree with historical facts.
Credit: https://www.luogu.org/discuss/show?postid=35727
Translated by ChatGPT 5
京公网安备 11011102002149号