显示代码纯文本
# include <iostream>
# include <cstdio>
using namespace std;
int n,m,sumsum=0,sum1[1000010]={0},maxx=-1,ans=0,maxy=-1;
char sky[1502][1502];
int dfs(int x,int y){
if(x>=1&&x<=n&&y>=1&&y<=m)
if(sky[x][y]=='*'){
sumsum++;
sky[x][y]='.';
if(sky[x][y-1]=='*'){
dfs(x,y-1);
}
if(sky[x][y+1]=='*'){
dfs(x,y+1);
}
if(sky[x-1][y-1]=='*'){
dfs(x-1,y-1);
}
if(sky[x+1][y+1]=='*'){
dfs(x+1,y+1);
}
if(sky[x-1][y+1]=='*'){
dfs(x-1,y+1);
}
if(sky[x+1][y-1]=='*'){
dfs(x+1,y-1);
}
if(sky[x+1][y]=='*'){
dfs(x+1,y);
}
if(sky[x-1][y]=='*'){
dfs(x-1,y);
}
}
}
int main(){
freopen("noi_online2020_star.in","r",stdin);
freopen("noi_online2020_star.out","w",stdout);
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin >>sky[i][j];
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(sky[i][j]=='*'){
dfs(i,j);
sum1[sumsum]++;
maxx=max(maxx,sumsum);
sumsum=0;
}
}
}
for(int i=1;i<=maxx;i++){
if(sum1[i]!=0){
ans++;
maxy=max(maxy,sum1[i]*i);
}
}
printf("%d\n%d",ans,maxy);
fclose(stdin);
fclose(stdout);
return 0;
}