Artillery positionsTime Limit: 2000 msmemory limit: 65536 kbthis problem will be judged on PKU. Original ID: 1185
64-bit integer Io format: % LLD Java class name: generals of main command intend to deploy their artillery troops on the grid map of N * m. A n * m map consists of N rows and M columns. Each grid of the map may be a mountain (represented by "H") or a plain (represented by "p ), for example. A maximum of one artillery unit can be deployed on each plain terrain (the artillery unit cannot be deployed on the mountain). The black area of an artillery unit in the attack range on the map is shown:
If an artillery force is deployed on the gray plain marked by the map, the Black Grid in the figure indicates the area to which it can attack: two grids along the horizontal left and right, the two cells are vertical and vertical. No other white mesh attacks can be found on the graph. The artillery attack range is not affected by the terrain.
Now, the generals plan how to deploy artillery troops to prevent accidental injuries (ensure that no two artillery troops can attack each other, that is, no artillery force is within the attack scope of other Artillery Forces.) the maximum number of Artillery Troops in our army can be placed in the whole map area.
The first line of input contains two positive integers separated by spaces, representing N and m respectively;
In the next n rows, each row contains M consecutive characters ('P' or 'H') with no spaces in the middle. Represent the data of each row in the map in order. N <= 100; m <= 10. Only one line of output contains an integer k, indicating the maximum number of artillery troops that can be placed. Sample Input
5 4PHPPPPHHPPPPPHPPPHHP
Sample output
6
Sourcenoi 01 problem solving: Pressure DP, my first state compresses DP. The code will be sent tomorrow.