ZOJ 2165 Red and Black
来源:互联网 发布:沙皇尼古拉一世数据 编辑:程序博客网 时间:2024/05/22 16:02
格子类搜索
#include<iostream>#include<cstdio>#include<string.h>using namespace std;const int N=22;char mp[N][N];int n,m,ans,visit[N][N];int v[4][2]={0,1,0,-1,1,0,-1,0};void dfs(int x,int y){visit[x][y]=1;ans++;for(int i=0;i<4;i++){int nx=x+v[i][0],ny=y+v[i][1];if(!visit[nx][ny]&&mp[nx][ny]=='.')dfs(nx,ny);}}void solve(){ans=0;memset(visit,0,sizeof visit);for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)if(mp[i][j]=='@'){dfs(i,j);printf("%d\n",ans);return;}}int main(){while(cin>>m>>n){//m列n行if(n==0&&m==0) break;memset(mp,'#',sizeof mp);for(int i=1;i<=n;i++)scanf("%s",mp[i]+1);solve();}return 0;}
0 0
- zoj 2165 Red and Black
- ZOJ-2165 red and black
- ZOJ-2165 Red and Black
- zoj 2165 Red and Black
- ZOJ 2165 Red and Black
- ZOJ 2165 Red and Black
- zoj 2165(hdu1312) Red and Black(深搜)
- poj 1979 zoj 2165 Red and Black
- zoj 2165 Red and Black (BFS)
- ZOJ 2165 Red and Black (floodfill)
- ZOJ Problem Set - 2165 Red and Black
- zoj 2165 || poj 1979 Red and Black(BFS水水)
- poj 1979 zoj 2165 Red and Black 深搜做法
- zoj 2165||poj 1979 red and black (dfs)
- POJ 1979 Red and Black (zoj 2165) DFS
- ZOJ 2165 POJ 1979 Red and Black DFS水题
- ZOJ 2165 Red and Black(DFS,水题)
- Red and Black
- poj2773求第K个与m互质的数
- AlertDialog对话框
- JAVA基础②
- 唉,程序员要是自学能力不行就等死吧!
- vs2013代码搜索的插件(Bing Code Search)
- ZOJ 2165 Red and Black
- windows平台WorkBench远程连接MySQL失败
- Oracle中协议适配器错误
- Android三种解析XML方式
- 随想
- leetcode: Evaluate Reverse Polish Notation
- 数据库中字符串的连接
- STM32移植FATFS文件系统
- 《JAVA与模式》之门面模式