GALERIJA | 프로그래밍의 벗 PivotOJ
PivotOJ

GALERIJA

시간 제한: 2000ms메모리 제한: 128MB출처: CHC 2003 National Competition #2 - JuniorsBOJ 2115
이 문제는 본문 이미지 일부가 표시되지 않습니다. 텍스트만으로 풀이가 어려울 수 있습니다.

문제

Map of an art gallery can be represented by a square grid of M columns and N rows. Some of the squares are walls while others represents empty space. 

Rooms consist of adjacent free squares (squares that share edge). On the walls of the rooms we want to hang as many pictures as possible. Every picture occupies exactly two lengths of a square and their height doesn’t matter. In other words you can hang a picture on the wall if there are two consecutive walls and two free squares opposite of them (that two free squares should, of course, be at the same side of walls). 

Write a program that computes the maximum number of pictures that can be hanged on the walls. 

[이미지 1]

This picture shows one of the possible solutions for a gallery map. 

입력

In the first line of the input file there are two integers M and N, 1 ≤ M,N ≤ 1000, number of the rows and number of the columns of the gallery. 

In the next M rows there are N characters. Every character represents either a free square or wall. ‘X’ represents wall and ‘.’ represents free space. 

First and last row, as well as first and last column are walls. 

출력

In the first line of file you should write maximum number of pictures that can be hanged on walls of gallery

예제

예제 1

입력
3 3
XXX
X.X
XXX
출력
0

예제 2

입력
5 5
XXXXX
X...X
X.XXX
X.X.X
XXXXX
출력
4

예제 3

입력
7 10
XXXXXXXXXX
X.X.X....X
XXX.X.XX.X
XX....XX.X
X.XX..X..X
X..XX...XX
XXXXXXXXXX
출력
14
코드를 제출하려면 로그인하세요.