hdu 2952
来源:互联网 发布:c语言函数库大全 编辑:程序博客网 时间:2024/06/05 17:17
体会到了搜索的魅力。。
广搜题,以一个点#为中心向四周搜索,把相邻的#全找出来并标记为".";;
#include<stdio.h>
#include<string.h>
int dir[4][2]={0,1, 0,-1, -1,0, 1,0};
char map[200][200];
int sum;
void bfs(int x,int y)
{
int i,x1,y1;
for(i=0;i<4;i++)
{
x1=x+dir[i][0];
y1=y+dir[i][1];
if(map[x1][y1]=='#')
{
map[x1][y1]='.';
bfs(x1,y1);
}
}
}
int main()
{
int m,n,i,j,k;
scanf("%d",&k);
while(k--)
{
sum=0;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
scanf("%s",map[i]);
for(i=0;i<n;i++)
for(j=0;j<m;j++)
{
if(map[i][j]=='#')
{
sum++;
bfs(i,j);
}
}
printf("%d\n",sum);
}
return 0;
}
- hdu 2952
- HDU-2952 BFS
- HDU 2952 Counting Sheep
- hdu 2952 Counting Sheep
- hdu-2952-Counting Sheep
- hdu 2952 Counting Sheep
- hdu 2952Counting Sheep
- HDU 2952 Counting Sheep
- hdu 2952 Counting Sheep
- HDU 2952 Counting Sheep
- hdu 2952 Counting Sheep
- hdu 2952 Counting Sheep
- HDU 2952 Counting Sheep
- hdu 2952 Counting Sheep
- hdu 2952 Counting Sheep
- hdu 2952 Counting Sheep
- hdu 2952 Counting Sheep
- HDU 2952 Counting Sheep
- 关于“Could not find a valid gem 'bundler' (>= 0) in any repository” 解决办法。
- 汇编—二进制,十进制,十六进制 互转
- C++构造函数虚拟化
- [转]JavaSE学习 Swing(二)
- [leetcode]Insert Interval
- hdu 2952
- 矩阵键盘驱动原理
- [转]JavaSE学习 Swing(一)
- 意外发现的J2K的编解码对比
- 深入理解Hadoop集群和网络
- JavaSE学习 第十三章 Swing基础
- js中解决float相加结果精度错乱的问题
- 狗狗40题
- hi_keypad.ko编译