zoj 2165 Red and Black
来源:互联网 发布:淘宝卖家怎样添加客服 编辑:程序博客网 时间:2024/05/16 16:23
//简单题,深搜或宽搜都可以。
#include<cstdio>#define MAX 21int w,h;int count;int grid[MAX][MAX];int dir[4][2]={ 0,1, 1,0, 0,-1, -1,0};void dfs(int x,int y){ count++; grid[x][y]='#'; int i,xx,yy; for(i=0; i<4; i++) { xx=x+dir[i][0],yy=y+dir[i][1]; if(xx<0||yy<0||xx>=h||yy>=w) continue; if(grid[xx][yy]=='.') dfs(xx,yy); }}int main(){ int i,j; int sx,sy; while(scanf("%d %d",&w,&h)){ getchar(); if(w==0&&h==0) break; count=0; for(i=0; i<h; i++) { for(j=0; j<w; j++) { scanf("%c",&grid[i][j]); if(grid[i][j]=='@') {sx=i,sy=j;} } getchar(); } dfs(sx,sy); printf("%d\n",count); } return 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
- 基础知识--确定本机到另外一台机器中路由器的个数
- Java和C++中的嵌套类讨论
- 最新版ZMQ3.2.3
- 实作PHP表单图形验证码验证码
- UVa:10074 Take the Land
- zoj 2165 Red and Black
- ZOJ 3195 Design the city (在线LCA,4级)
- sqlserver中返回两个日期间相差几年零几月零几天,DATEDIFF通常不准确
- C++抽象工厂模式举例
- MyGUI的align table
- Windows Server 2008 IE 无法调整安全级别 的解决方案
- JSON for java入门总结
- 《火球——UML大战需求分析》(第2章 耗尽脑汁的需求分析工作)——2.1 需求分析面面观
- eclipse中如何安装插件