Start: Dec, 04, 2016 12:00:00
杭州师范大学第十届程序设计竞赛—正式
End: Dec, 04, 2016 17:00:00
Time elapsed:
Time remaining:

Problem_ID: H
Result: Accepted
Time: 450ms
Memory: 36996kB
In contest: 1075

#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
int g[3005][3005];int dp[3005],res[3005]={0};
int main(){
	int h,w;
	memset(dp,0,sizeof(dp));
	cin>>h>>w;getchar();
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			scanf("%c",&g[i][j]);
		}
		getchar();
	}
	
	for(int i=0;i<=h+1;i++){//hang
		g[i][0]='.';
		g[i][w+1]='.';
	}
	for(int j=0;j<=w+1;j++){//lie
		g[0][j]='.';
		g[h+1][j]='.';
	}
	for(int i=1;i<=h;i++){
		int x=0;
		for(int j=1;j<=w;j++){
			int cur=dp[j];
			if(g[i][j]=='.') dp[j]=0;
			else{
				dp[j]=min(x,dp[j])+1;
			}
			x=min(cur,dp[j]);
			res[i]=max(res[i],dp[j]);
		}
	}
	int ans=-1;
	for(int i=1;i<=h;i++){
		ans=max(ans,res[i]);
	}
	printf("%d\n",(ans+1)/2);




	return 0;
}