hdu 1312 Red and Black dfs
来源:互联网 发布:php对接微信公众平台 编辑:程序博客网 时间:2024/05/16 09:30
简单dfs
#include<iostream>#include<cstring>#include<cstdio>#include<algorithm>#include<vector>#include<cmath>using namespace std;int f[4][2]={0,1,1,0,0,-1,-1,0};char a[21][21];int tmp,n,m;void dfs(int x,int y){ int x1, y1; for(int i=0;i<4;i++) { x1=x+f[i][0];y1=y+f[i][1]; if(x1<m&&x1>=0&&y1<n&&y1>=0&&a[x1][y1]=='.') { a[x1][y1]='#'; tmp++; dfs(x1,y1); //a[x1][y1]='.'; } }}int main(){ int x,y; while(cin>>n>>m) { getchar(); if(n==0&&m==0) break; for(int i=0;i<m;i++) for(int j=0;j<n;j++) { cin>>a[i][j]; if(a[i][j] == '@') {x=i;y=j;} } tmp=1; dfs(x,y); cout<<tmp<<endl; }}
- hdu 1312 Red and Black(dfs入门)
- hdu 1312 Red and Black dfs
- hdu 1312 Red and Black (简单dfs)
- hdu 题目1312 Red and Black ( DFS )
- HDU--1312 -- Red and Black [简单DFS]
- HDU 1312 Red and Black(BFS,DFS)
- HDU 1312 Red and Black (DFS入门)
- hdu 1312 Red and Black (bf、dfs)
- DFS-HDU 1312 -Red and Black
- hdu 1312 Red and Black(DFS)
- HDU--1312:Red and Black (DFS)
- HDU-#1312 Red and Black(DFS)
- HDU 1312 -- Red and Black(dfs)
- HDU 1312--Red and Black【DFS】
- HDU 1312Red and Black dfs
- hdu 1312 Red and Black(DFS)
- HDU - 1312 Red and Black (dfs)
- hdu 1312 Red and Black DFS
- 观察者模式
- ubuntu 12.04中超强两笔输入法的安装与配置
- WCF技术剖析之十三:序列化过程中的已知类型(Known Type)
- android camera(一):camera模组CMM介绍
- Hadoop处理数据的轨迹
- hdu 1312 Red and Black dfs
- WCF技术剖析之十四:泛型数据契约和集合数据契约(上篇)
- 如何营造游戏的打击感
- IOS自带字体
- Android内存之VSS/RSS/PSS/USS
- WCF技术剖析之十四:泛型数据契约和集合数据契约(下篇)
- hibernate二级缓存配置总结
- C语言中求程序运行时间
- android camera(二):摄像头工作原理、s5PV310 摄像头接口(CAMIF)