Result: Accepted
Time: 2ms
Memory: 2228kB
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string>
using namespace std;
int x,y;
char map[110][110];
int all=0;
int flag = 0;
int judge(int a,int b){
if(map[a][b]=='*'){return 0;}
else if(map[a][b]=='.'){
map[a][b]='*';
int now = judge(a,b-1)+judge(a,b+1)+judge(a-1,b)+judge(a+1,b);
if( a-1==0 || a+1==x+1 || b-1==0 || b+1 ==y+1){
return 1;
}
return now;
}
}
int main(){
scanf("%d%d",&x,&y);
getchar();
for(int i=0;i<=y+1;++i){map[0][i]='.';map[x+1][i]='.';}
for(int i=0;i<=x+1;++i){map[i][0]='.';map[i][y+1]='.';}
for(int i=1;i<=x;++i){
for(int j=1;j<=y;++j){
scanf("%c",&map[i][j]);
}
getchar();
}
for(int i=1;i<=x;++i){
for(int j=1;j<=y;++j){
if(map[i][j]=='.'){
flag=judge(i,j);
if(flag ==0 ){
all++;
}
}
}
}
cout<<all<<endl;
}