시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 7 6 6 85.714%

문제

It's Bessie's feeding time, and Farmer John is trying to decide where to put her. FJ has a farm that comprises W x H (1 <= W <= 750; 1 <= H <= 750) squares and is partitioned into one or more separate pastures by rocks both large and small. Every pasture contains some grass and some rocks.

Bessie is a hungry little cow and just loves to eat, eat, eat her grass. She can move from any square to any other square that is horizontally, vertically, or diagonally adjacent. Bessie can't cross the rocks because they hurt her feet, and, of course, she can't leave the farm. Bessie wants to know the maximum number of squares of grass that she can eat.

FJ has a map of his farm, where a '.' represents a square of grass, and a '*' represents a rock. Consider this 10x8 map and a detailed breakdown of the extent of each of its three pastures:

      ...*....**  |  111*....**   ...*2222**    ...*....**
      ..**....**  |  11**....**   ..**2222**    ..**....**
      ...*....**  |  111*....**   ...*2222**    ...*....**
      ...**.*.**  |  111**.*.**   ...**2*2**    ...**.*.**
      ***.**.***  |  ***1**.***   ***.**2***    ***.**.***
      ...**.*.**  |  111**.*.**   ...**2*2**    ...**.*.**
      ...*.*****  |  111*.*****   ...*2*****    ...*.*****
      ...***..**  |  111***..**   ...***..**    ...***33**

Pasture 1 has 21 squares; pasture 2 has 18 squares; pasture 3 has 2 squares. Thus Bessie should choose pasture 1 with 21 squares to maximize the grass she can eat.

입력

  • Line 1: Two space-separated integers: W and H
  • Lines 2..H+1: Line i+1 describes field row i with W characters (and no spaces), each either '.' or '*'

 

출력

  • Line 1: A single integer that represents the maximum number of squares of grass that Bessie can eat.

 

예제 입력

10 8
...*....**
..**....**
...*....**
...**.*.**
***.**.***
...**.*.**
...*.*****
...***..**

예제 출력

21

힌트