#P3170. [CQOI2015] 标识设计

    ID: 2219 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>动态规划,dp搜索2015重庆各省省选记忆化搜索

[CQOI2015] 标识设计

Description

A company abbreviated as LLL is designing a logo. Their initial plan is to place 33 L-shaped patterns and some extra decorative shapes on a square grid, for example: (the gray area denotes decorative shapes).

The 33 L-shaped patterns and the decorative shapes are all placed on the grid, and together they must cover the entire grid. The horizontal and vertical strokes of each L may have any positive length, but each length must be greater than 00 (i.e., an L cannot degenerate into a straight line segment). In addition, to keep the L patterns clear and recognizable, the 33 L-shaped patterns must not overlap or cross each other. Of course, an L-shaped pattern also cannot pass through or overlap any decorative shape.

Now that the designer has fixed the positions of all decorative shapes, please compute how many different logos can be designed by placing the L-shaped patterns.

Input Format

The first line contains two space-separated positive integers nn and mm, the numbers of rows and columns of the grid.

The next nn lines each contain mm characters. In the (i+1)(i + 1)-th line, the jj-th character denotes the cell at row ii, column jj. Each character is either . or #. # means the cell is a decorative shape, and . means it is an empty cell where an L-shaped pattern may be placed.

Output Format

Output a single integer, the total number of possible logos.

4 4
....
#...
....
..#.
4

Hint

Constraints

For 100%100\% of the testdata, 2n,m302\le n,m\leq 30.

Translated by ChatGPT 5