简单题目的dfs模版
来源:互联网 发布:手机直播软件排名 编辑:程序博客网 时间:2024/06/04 23:57
#include<iostream>#include<cstdio>#include<algorithm>#include<string>#include<cstring>#include<cstdlib>#include<set>#include<map>#include<vector>#include<iomanip>const int MAX=200;using namespace std;char arr[MAX][MAX];int dir[4][2]={{1,0},{0,1},{-1,0},{0,-1}};int w,h; int sum=1;int dfs(int x,int y){ arr[x][y]='#'; for(int k=0;k<4;k++) { int dx=x+dir[k][0]; int dy=y+dir[k][1]; if(0<dx&&dx<=h&&0<dy&&dy<=w&&arr[dx][dy]=='.') { sum++; dfs(dx,dy); } } return 0;}int main(){while(scanf("%d%d",&w,&h)&&w&&h){ int beg,end; for(int i=1;i<=h;++i) { for(int j=1;j<=w;++j) { cin>>arr[i][j]; if(arr[i][j]=='@') { beg=i; end=j; } } } dfs(beg,end); printf("%d\n",sum); sum=1;}return 0;}
0 0
- 简单题目的dfs模版
- dfs简单题目
- hdu1584 dfs的题目
- 模版的简单使用
- 简单的函数模版
- 简单的继承模版
- 简单模版的使用
- 一个简单的模版控件
- 简单的ant模版forJB2005
- 简单的socket编程模版
- 一个简单的makefile模版
- 一个简单的函数模版
- poj1573(简单的dfs)
- poj3051(简单的dfs)
- DFS的简单应用
- DFS题目
- dfs bfs模版
- bfs及dfs模版
- bfs模板
- 攻克GRE数学中的图表题
- Liunx下解决svn: Cannot negotiate authentication mechanism错误问题
- eclipse中常用的快捷键
- 斗西游
- 简单题目的dfs模版
- HMM-前向后向算法
- Problem J: Home on the Range 家的范围
- 代码注释,神兽护体,代码无bug
- Gradle使用手记:安装
- 使用Ubuntu DatePicker来选择时间
- iOS CoreData详解(六)深入理解数据模型
- cocos2dx[3.2] ——数学类Vec2/Size/Rect
- STM32F107开发板ping电脑程序