Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 用 bool16ms,用char 0ms

Posted by czjxy881 at 2012-07-27 19:49:53 on Problem 1562
```#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
char map[102][102];
void v(int x,int y,int n)
{
if(n>100||!map[x][y])return;
map[x][y]=0;n++;
v(x-1,y-1,n);v(x,y-1,n);v(x+1,y-1,n);
v(x-1, y ,n);           v(x+1, y ,n);
v(x-1,y+1,n);v(x,y+1,n);v(x+1,y+1,n);
return;
}
bool solve()
{
int m,n,i,j,ans=0;
scanf("%d%d",&m,&n);
if(!(m+n))return 0;
char t;
for(i=1;i<=m;i++)
{
while(getchar()!='\n');
for(j=1;j<=n;j++)
{
t=getchar();
if(t=='@')map[i][j]=1;
else map[i][j]=0;
}
map[i][j]=0;
}
for(j=1;j<=n;j++) map[i][j]=0;
for(i=1;i<=m;i++)
for(j=1;j<=n;j++)
if(map[i][j]){ans++;v(i,j,1);}
printf("%d\n",ans);
return 1;
}
int main()
{
while(solve());
return 0;
}
```

Followed by: