2612专题

HDU 2612 水BFS

两个人(Y和M)要在‘@’处相遇,图中有不定个‘@’; 对每个人做一遍BFS即可,然后枚举每个‘@’位置 #include "stdio.h"#include "string.h"#include "queue"using namespace std;const int inf=0x7fffffff;const int dir[4][2]={{1,0},{-1,0},{0,

find a way HDU-2612

Pass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally. Leave Ningbo one year, yifenfei have many people to meet. Especially a good friend Merceki. Yifenfei’s home is at the cou

N - Find a way HDU - 2612(BFS)

Pass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally. Leave Ningbo one year, yifenfei have many people to meet. Especially a good friend Merceki. Yifenfei’s home is at the cou

【hdu1241Oil Deposits】【HDU 2612 Find a way】

HDU1241Oil Deposits 求联通块数量 Sample Input 1 1 * 3 5 *@*@* **@** *@*@* 1 8 @@****@* 5 5  ****@ *@@*@ *@**@ @@@*@ @@**@ 0 0  Sample Output 0 1 2 2 DFS:   #include <iostream>#include<cstdio>#include <io

hdu 2612 Find a way(BFS)

原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=2612 题目大意: Y与M到任意一个'@'所需最少时间。 思路: 两遍BFS计算出Y到任意一个’@‘的所需时间以及M到任意一个’@‘的所需时间,求和的最小值。 哎,挺简单的就是不知道最初写的哪有bug。 求bug。。T.T 正确代码如下: #inc

Find a way HDU - 2612 (两路bfs+查表)

细节: 1.需要用dis数组保存到每个点的最短路,因为这里需要多次查询路径(如果kfc很多的话) 2. 整张图的dis初始化为一个很大的值,这里用0x3f3f3f3f,因为这足够大而且两个最大相加不会溢出~ #include <cstdio>#include <cstring>#include <queue>using namespace std;const int maxn = 20

hdu 2612 Find a way【BFS】

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2612 题意:y和m要在kfc见面,问你能否选择一家kfc使得y和m到那里的距离最短 解析:两个人都跑一遍bfs,然后枚举每家kfc,找出最优的即可 #include <iostream>#include <cstdio>#include <cstring>#include <algorit