P28035 [洛谷] [SHUPC 2024] Land Battler!
普及
题目描述

Background

A card game called "Land Battler" has deeply attracted Little A. Currently, Little A is practicing card placement, but she is not proficient in it, so she wants to consult you, who is skilled in programming, to solve this problem.

Problem Description

The game's specific rules are as follows: The game is played on a $n \times m$ grid matrix, where . represents a grid that can be placed on, and # represents a grid that cannot be placed on. You have 4 different shaped cards, each of which only has one copy. You need to place the cards on the board. The cards can be placed at any position, but the grids occupied by the cards cannot overlap, nor can they be placed on grids that cannot be placed on. The goal is to maximize the number of grids occupied by the cards. Little A wants to know, under the optimal placement strategy, how many grids can be occupied at most?

Card Shapes

Input Format

The first line contains two positive integers $n, m\ (1 \le n, m \le 10)$.

The next $n$ lines, each containing $m$ characters, guarantee that the characters are only . and #, representing the placement type of the board.

Output Format

Output a single integer representing the answer.

Sample Input and Output

Sample Input #1

3 3
...
...
...

Sample Output #1

9

Sample Input #2

3 3
..#
.#.
#..

Sample Output #2

4

Notes

Sample Explanation:

For Sample 1, the optimal placement method is as follows, using the first and second cards, a maximum of 9 grids can be occupied.

Sample 1 Placement

For Sample 2, the optimal placement method is as follows, using the second card, a maximum of 4 grids can be occupied, with red representing grids where cards cannot be placed.

Sample 2 Placement

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 3 ... ... ...
样例输出
9