City makes a plan for buildings and parking lots on land. The land can be divided into equal sized tiles. Each tile is either a building or parking lot. The height difference between building/parking lots on two adjacent tiles is no more than one. The locations of parking lots on the land are fixed. Write a function to find what is the highest building can be planned. [Adjacency only includes left, right, up and down. Specifically diagonal is not considered - two tiles share an edge to be considered as adjacent]
Example 1
Input
- - -
- - -
- - POutput: 4 with following arrangement
4 3 2
3 2 1
2 1 PExample 2
Input
- - P
- - -
- - POutput: 3 with following arrangement
2 1 P
3 2 1
2 1 P