hdu 1312 Red and Black
来源:互联网 发布:embase数据库 编辑:程序博客网 时间:2024/05/16 18:20
hdu 1312 Red and Black 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1312
DFS水
题目大意:一个人被困在一个迷宫里,问他的生存空间。
题目分析:DFS就好了。
code:
#include<cstdio>#include<cstring>char mp[26][26],vis[26][26];int m,n,dir[4][2]={1,0,-1,0,0,1,0,-1},sum;int judge(int x,int y){return x>=0&&y>=0&&x<m&&y<n&&mp[x][y]=='.'?1:0;}void dfs(int x,int y){mp[x][y]='#';sum++;for(int i=0;i<4;i++){int xx=x+dir[i][0],yy=y+dir[i][1];if(judge(xx,yy))dfs(xx,yy);}}int main(){int i,j,sx,sy;while(scanf("%d%d",&n,&m)!=EOF&m|n){sum=0;for(i=0;i<m;i++){scanf("%s",mp[i]);for(j=0;j<n;j++){if(mp[i][j]=='@')sx=i,sy=j;}}dfs(sx,sy);printf("%d\n",sum);}return 0;}
15MS 232K 603B
PS:无tricker水
- Red and Black hdu 1312
- HDU 1312 Red and Black
- HDU 1312 Red and Black
- hdu 1312 Red and Black
- Hdu 1312 - Red and Black
- hdu-1312-Red and Black
- hdu 1312Red and Black
- hdu 1312 Red and Black
- hdu - 1312 - Red and Black
- hdu 1312 Red and Black
- hdu 1312 Red and Black
- HDU-1312(red and black)
- HDU 1312 Red and Black
- hdu 1312 Red and Black
- HDU 1312 Red and Black
- hdu 1312 Red and Black
- hdu 1312 Red and Black
- hdu 1312 Red and Black
- 1.6
- RMAN无控制文件恢复
- 常用array函数
- android 如何检查机器是否已经root
- Owning Dell DRAC for ONE AWESOME HACK!
- hdu 1312 Red and Black
- Ubuntu 13.04编译boost1.54
- 解函数方程
- Flex之旅--AdvancedDataGrid 修改树节点图标
- WP7-常用控件简介
- 简单实现web服务器负载均衡
- Java单例对象同步问题探讨
- Oracle Data Guard Switchover 切换
- zoj 3689 Digging (dp)