#Q173. 「一本通 5.4 例 2」牧场的安排

    ID: 2255 Type: Default 1000ms 512MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>DP状态压缩早于 2010USACO Contest一本通提高

「一本通 5.4 例 2」牧场的安排

Description

Original Source: USACO 2006 Nov. Gold

Farmer John has recently purchased a new rectangular pasture, which is divided into MM rows and NN columns (1M12;1N12)(1≤M≤12; 1≤N≤12). Each cell is a square plot of land. FJ plans to plant delicious grass in some of these plots for his cows to enjoy. Unfortunately, some of the land is quite barren and cannot be used for grazing. Additionally, cows prefer to have exclusive access to a grassy area, so FJ will not select two adjacent plots—meaning no two grassy plots share a common edge. Of course, FJ has not yet decided which plots to plant with grass.

As a curious farmer, FJ wants to know how many different planting schemes are available to him, without considering the total number of grassy plots. Leaving the entire pasture unused (i.e., planting no grass at all) also counts as one valid scheme. Please help FJ calculate this total number of schemes.

Input Format

Line 11: Two positive integers MM and NN, separated by a space;
Lines 22 to M+1M+1: Each line contains NN space-separated integers describing the state of each plot. The (i+1)(i+1)-th line describes the plots in the ii-th row. All integers are either 00 or 11, where 11 indicates the plot is fertile enough, and 00 means the plot is unsuitable for planting grass.

Output Format

Line 11: Output an integer, which is the total number of pasture allocation schemes modulo 10810^8.

Sample 1

Label the plots as shown below:

1 2 3
0 4 0

There are 44 schemes for planting grass in a single plot: choosing any one of 1,1, 2,2, 3,3, or 44. For planting grass in two plots, there are 33 schemes: 13,13, 1414, and 3434. There is only one scheme for planting grass in three plots: 134134. Adding the option of leaving the pasture unused, the total number of schemes is 4+3+1+1=94+3+1+1=9.

2 3
1 1 1
0 1 0

9

Constraints and Hints

1N,M121\le N,M\le 12.