| 记录编号 | 
        44216 | 
        评测结果 | 
        AAAAAAAAAA | 
    
    
        | 题目名称 | 
        1165.家族 | 
        最终得分 | 
        100 | 
            
    
    
        | 用户昵称 | 
         Makazeu | 
        是否通过 | 
        通过 | 
    
    
        | 代码语言 | 
        C++ | 
        运行时间 | 
        0.011 s  | 
    
    
        | 提交时间 | 
        2012-10-17 10:15:45 | 
        内存使用 | 
        3.65 MiB  | 
        
    
    
    
    		显示代码纯文本
		
		#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <string>
#include <utility>
#include <queue>
#include <iostream>
#include <algorithm>
using namespace std;
const int MAXN=222;
typedef pair<int,int> Pair;
int N,map[MAXN][MAXN]={0};
string tmp;int len;
const int step[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
int flag[MAXN][MAXN]={0},leng[MAXN],Ans=0;
inline void init()
{
	scanf("%d",&N); getline(cin,tmp);
	for(int i=1;i<=N;i++)
	{
		tmp.clear();
		getline(cin,tmp);
		len=tmp.length();
		for(int j=1;j<=len;j++)
		{
			if(tmp[j-1]==11 || tmp[j-1]==13) break;
			if(isalpha(tmp[j-1])) map[i][j]=1;
			else map[i][j]=0;leng[i]=j;
		}
	}
}
queue<Pair> q;
inline void bfs(int a,int b)
{
	Pair tp; int x,y;
	q.push(make_pair(a,b));
	flag[a][b]=1;
	while(q.size())
	{
		tp=q.front(); q.pop();
		for(unsigned int i=0;i<4;i++)
		{
			x=tp.first+step[i][0];
			y=tp.second+step[i][1];
			if((!map[x][y])||(flag[x][y])) continue;
			flag[x][y]=1; q.push(make_pair(x,y));
 		}
	} 
}
inline void work()
{
	for(int i=1;i<=N;i++)
	{
		for(int j=1;j<=leng[i];j++)
		{
			if(!map[i][j]) continue;
			if(flag[i][j]) continue;
			Ans++; bfs(i,j);
		}
	}
}
int main()
{
	freopen("family.in","r",stdin);
	freopen("family.out","w",stdout);
	init();
	work();
	printf("%d\n", Ans);
	return 0;
}