hdu 2952 Counting Sheep
来源:互联网 发布:什么是旋转变换矩阵 编辑:程序博客网 时间:2024/04/28 02:32
#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <stack>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#include <time.h>using namespace std;int n,m,vis[104][104];int dx[]={0,0,1,-1};int dy[]={-1,1,0,0};char mp[104][104];void dfs(int x,int y){ vis[x][y]=1; int i,tx,ty; for(i=0;i<4;i++) { tx=dx[i]+x; ty=dy[i]+y; if(tx<0||tx>=n||ty>=m||ty<0) continue; if(vis[tx][ty]==1||mp[tx][ty]=='.') continue; dfs(tx,ty); }}int main(){ int t,cnt,i,j; scanf("%d",&t); while(t--) { scanf("%d%d",&n,&m); for(i=0;i<n;i++) scanf("%s",mp[i]); memset(vis,0,sizeof(vis)); cnt=0; for(i=0;i<n;i++) for(j=0;j<m;j++) { if(mp[i][j]=='#'&&!vis[i][j]) { cnt++; dfs(i,j); } } printf("%d\n",cnt); } return 0;}
0 0
- 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
- HDU-2952-Counting Sheep
- hdu 2952 Counting Sheep(dfs)
- OSPF(三):邻居
- 有关Android category 相关的解释
- 【Unity3d】Animator和Animation组件使用注意事项
- 微信公众平台开发者中心服务器配置Token验证失败问题
- 利用dropbox建立私有Repo
- hdu 2952 Counting Sheep
- OSPF(四):区域
- declare-styleable (自定义控件的编写)
- (15.1.10)FTP服务器配置以及访问
- OSPF(五):链路状态数据库
- RecycleView 明明有数据却显示不出来?
- iOS开发之Xcode6之后不再自动创建Pch预编译文件
- Clean Code 读书笔记八
- 解决Nginx的connect() to 127.0.0.1:8080 failed (13: Permission denied) while connect