HDU 1026 Ignatius and the Princess I(广搜+记录路径)
摘要:题意:骑士,就暂且叫他骑士,要去就城堡里的公主。题意是,找到即为救到。在路上可能遇到一些小怪,遇到怪就要打咯,需要花费相应的时间。解题思路:广搜+结构体记录路径+优先队列链接:http://acm.hdu.edu.cn/showproblem.php?pid=1026View Code #include <iostream>using namespace std;const int MAX =100+10;#include <queue>bool used[MAX][MAX];//标记该坐标是否呗更新过int dir[4][2]={{0,1},{1,0},{0,-1},
阅读全文
HDU 2717 Catch That Cow(简单广搜)
摘要:题意:输入两个数,start,end。从开始通过三种更新到end需要多少次。典型的广搜链接:http://acm.hdu.edu.cn/showproblem.php?pid=2717View Code #include <iostream>#include <queue>using namespace std;int n,m;#define MAX 200000+10bool used[MAX];struct node{ int n; int x;};int bfs(int start){ queue<node>q; node temp; memset(u
阅读全文
hdu 1180 诡异的楼梯(广搜)
摘要:题意:给定起点和终点,算时间。注意:判断扩展的点为'|'或者'-'时,到达此点楼梯的状态。本来能有优先队列做的,我犯贱咯!等一天补上优先队列的代码;连接:http://acm.hdu.edu.cn/showproblem.php?pid=1180View Code #include <iostream>using namespace std;#include <queue>const int MAX = 20+10;char map[MAX][MAX];//bool used[MAX][MAX];int starti,startj,n,m
阅读全文