
图与图遍历
ZeroLH00
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
UVA 10054 The Necklace#
UVA 10054 The Necklace题目大意:1~50代表颜色,俩个颜色一组,要求相连的组之间颜色相同,连成一条项链,并输出解题思路:判断是否连通,然后判断是否是欧拉回路,最后逆序输出#include <stdio.h> #include <iostream> #include <queue> #include <string.h> using namespace std; int all;原创 2016-08-16 19:46:04 · 345 阅读 · 0 评论 -
UVA 10557-XYZZY
UVA 10557-XYZZY题目大意:输入房间1~n,每个房间有能量,到那个房间需要加上能量,每个房间可以通往指定编号的房间,一开始能量为100在房间1,问能否到达房间n,中间能量不能小于等于0解题思路:先判断每个房间能通往那些房间,然后dfs,每次进入一个房间时记录当前房间能量,如果房间能通往房间n且进入能量大于记录中房间能量则dfs,中间要判断是否存在正环#include <stdio.h>原创 2016-08-12 21:40:25 · 630 阅读 · 0 评论 -
UVA 532-Dungeon Master
UVA 532-Dungeon Master题目大意:给出一个三维图,#代表障碍物,E代表出口,S代表初始位置,求离开的最短路解题思路:三维数组bfs求最短路#include <stdio.h> #include <iostream> #include <string.h> #include <queue> using namespace std; struct dun { int x, y原创 2016-08-12 17:09:16 · 412 阅读 · 0 评论 -
UVA 439-Knight Moves
UVA 439-Knight Moves题目大意:给出国际象棋棋盘俩个坐标,求马从坐标1到坐标2的最短步数解题思路:bfs寻找最短路#include <stdio.h> #include <iostream> #include <queue> #include <string.h> using namespace std; struct kni{ int x, y, d; }; int di原创 2016-08-11 18:47:16 · 304 阅读 · 0 评论 -
UVA 705-Slash Maze
UVA 705-Slash Maze题目大意:由/和\形成迷宫,求有几个回路和最大回路的路长解题思路:把一个格子扩大俩倍,然后dfs求解#include <stdio.h> #include <iostream> #include <string.h> using namespace std; int map[400][400]; char ch[100][100]; int flag[400][4原创 2016-08-11 17:26:11 · 388 阅读 · 0 评论 -
UVA 784-Maze Exploration#
UVA 784-Maze Exploration题目大意:给出字符串,*代表人,X代表障碍物,将人能够到达的区域全部用#标记,然后打印解题思路:遍历找到*,然后dfs搜索#include <stdio.h> #include <iostream> #include <string.h> using namespace std; int l; char ch[50][100]; void dfs(in原创 2016-08-11 14:24:23 · 287 阅读 · 0 评论 -
UVA 657 The die is cast
UVA 657 The die is cast题目大意:给出字符串 *代表骰子区域,X代表点数,若几个X相邻代表是同一个点数,求出每个骰子共多少点数,并从小到大输出解题思路:用俩次dfs搜索,第一次搜索*的区域,然后搜索X#include <stdio.h> #include <iostream> #include <string.h> using namespace std; char ch[10原创 2016-08-11 13:50:53 · 317 阅读 · 0 评论 -
UVA 572-Oil Deposits
UVA 572-Oil Deposits题目大意:给出一个字符串的地理图,判断油田@的数目,几个@紧挨在一起算一个油田解题思路:先二维数组存好,然后将找到的油田变为*,递归调用函数#include <stdio.h> #include <iostream> #include <string.h> using namespace std; char str[1000][1000]; int s; in原创 2016-08-10 16:06:22 · 361 阅读 · 0 评论 -
UVA 10129 Play on Words
UVA 10129 Play on Words题目大意:判断首字母与末尾字母形成的若安路是否形成欧拉通路解题思路:判断是否连通,然后判断度数是否为偶数(起点和终点入度和出度可以相差1)#include <stdio.h> #include <iostream> #include <string.h> #include <stack> using namespace std; stack<int> s原创 2016-08-16 19:59:27 · 258 阅读 · 0 评论 -
UVA 10596 Morning Walk
UVA 10596 Morning Walk题目大意:判断是否是欧拉回路,独立点不算进来解题思路:判断除处理点以外的点是否连通,然后判断度数是否为偶数#include <stdio.h> #include <iostream> #include <string.h> using namespace std; int m, n; int on[300]; int reach[300][300]; in原创 2016-08-16 19:52:32 · 307 阅读 · 0 评论 -
UVA 10305 Ordering Tasks
UVA 10305 Ordering Tasks题目大意:做一系列工作,但工作有顺序之分,比如必须完成A才能做B,要求为工作排序解题思路:循环dfs#include <stdio.h> #include <string.h> #include <iostream> using namespace std; int wo[110][110]; int flag[110]; int m, n; int原创 2016-08-16 19:49:27 · 276 阅读 · 0 评论 -
UVA 10004-Bicoloring
UVA 10004-Bicoloring题目大意:给0~n的格子,以及哪些格子相连,问能否用俩种颜色涂格子使相连个字颜色不同解题思路:用栈记录相连格子以及记录个字颜色,dfs搜索,如果颜色与上回涂色不同则返回0#include <stdio.h> #include <iostream> #include <string.h> #include <stack> using namespace std;原创 2016-08-13 14:36:53 · 323 阅读 · 0 评论