UVA784Maze Exploration
来源:互联网 发布:java生产者和消费者 编辑:程序博客网 时间:2024/06/14 06:44
UVA-784
题意:给出n个图,每个图以一行_ 结束,其中*是初始位置,X是墙壁,求人可以走到的地方,并用#替换空格,输出整个图。
解题思路:找到人物在的位置,dfs开始遍历,到的地方就改成#。
/************************************************************************* > File Name: UVA-784.cpp > Author: Narsh > > Created Time: 2016年07月20日 星期三 13时56分32秒 ************************************************************************/#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>using namespace std;string s[60];int t,l;const int c[4][2]={{1,0},{0,1},{-1,0},{0,-1}};void dfs(int x, int y) { if (s[x][y] != ' ') return ; s[x][y]='#'; for (int i = 0; i < 4; i++) dfs(x+c[i][0],y+c[i][1]);}int main() { scanf("%d\n",&t); while (t--) { l=0; while (true) { l++; getline(cin,s[l]); s[l]=" "+s[l]; if (s[l][1] == '_') break; } for (int i = 1; i <= l; i++) for (int j = 1; j < s[i].length(); j++) if (s[i][j] == '*') { s[i][j]= ' '; dfs(i,j); } for (int i = 1; i <= l; i++){ for (int j = 1; j < s[i].length(); j++) printf("%c",s[i][j]); printf("\n"); } }}
0 0
- UVA784Maze Exploration
- pku3618 Exploration
- Exploration poj
- Data Exploration
- Treasure Exploration
- Maze Exploration
- poj2594Treasure Exploration
- WOJ1024-Exploration
- Treasure Exploration
- Treasure Exploration
- Treasure Exploration
- SilverLight Cache First Exploration
- UVa 784 Maze Exploration
- poj 2594 Treasure Exploration
- POJ 2594 Treasure Exploration
- poj 2594 Treasure Exploration
- poj 2594 Treasure Exploration
- 784 - Maze Exploration
- 希腊字母读法
- C++\C指针作为参数
- Android关于Jenkins+Gradle自动化构建时Gradle版本冲突的问题
- poj3461 KMP算法(字符串匹配)
- linux bus driver device 三者关系
- UVA784Maze Exploration
- HDU 5724 Chess(2016 Multi-University Training Contest 1的1002题)
- module_init()
- Android Espresso Test UI
- CentOS 7下MySQL 5.7安装、配置与应用
- 【酷我天气】完整的天气App项目
- 欢迎使用CSDN-markdown编辑器
- Hadoop--06--MapReduce编程基础
- 【BZOJ2049】[Sdoi2008]Cave洞穴勘测