Parking Party
Time limit2sMemory limit1024 MB
Given a grid with pillars, find the maximum number of cars that can park when each car enters along a row or column from either end.
Problem
Peyman has decided to host a dinner party at his house in Zabol. His house has a rectangular parking lot that can be represented by a grid with rows and columns. A car can park in one of the cells. Some cells are occupied by immovable pillars, so no car can park in or pass through them. Each row and each column has an entrance at both of its ends. When a car enters through an entrance, it moves straight forward along that row or column. It stops and parks when it reaches the opposite entrance, or when the next cell is occupied by a pillar or another parked car. A car cannot enter a row or column if its first cell is already occupied.
Peyman wants to park as many cars as possible. He can tell each arriving guest which entrance to take. Help Peyman reach this goal.
Input
The first line contains two integers and (), the number of rows and columns. Each of the next lines contains a string of length made of "." and "o" characters. The -th character of the -th line is "o" if the cell in row and column has a pillar, and "." if the cell is empty.
Output
Print a single integer , the maximum number of cars Peyman can park in the lot.