hust 1605 bfs】的更多相关文章

思路:直接用优先队列优化bfs. #include<map> #include<queue> #include<vector> #include<cmath> #include<string> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define Maxn 100010 #define in…
1605 - Gene recombination Time Limit: 2s Memory Limit: 64MB Submissions: 264 Solved: 46 DESCRIPTION As a gene engineer of a gene engineering project, Enigma encountered a puzzle about gene recombination. It is well known that a gene can be considered…
简单广搜.4进制对应的10进制数来表示这些状态,总共只有(4^12)种状态. #include<cstdio> #include<cstring> #include<cmath> #include<map> #include<queue> #include<algorithm> using namespace std; ; ]; struct P { int state; int tot; }; queue<P>Q; ch…
题目描述 As a gene engineer of a gene engineering project, Enigma encountered a puzzle about gene recombination. It is well known that a gene can be considered as a sequence, consisting of four nucleotides, which are simply denoted by four letters, A, C,…
巡逻机器人 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=83498#problem/F 题目大意: 机器人在一个矩形区域巡逻,是一网格(m行和n列).从左上角(1,1)到右下角(m,n).网络格 中的一些格子是空地(用0表示),其他格子是障碍(用1表示).机器人每次有4个方向走,但不能 连续穿越k障碍,求最短长度. 分析: 用bfs进行搜索,不过当遇到障碍的时候记录下,当遇到的障碍超过k时,返回到上一步. #include…
骑士的移动 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=83498#problem/E 题目: Description A friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight moves that visits each s…
转载自:  http://m.blog.csdn.net/blog/Enjoying_Science/42008801 题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=49880 题意:7数码问题.在2×4的棋盘上,摆有7个棋子,每个棋子上标有1至7的某一数字,不同棋子上标的数字不相同.棋盘上还有一个空格(用0表示),与空格相邻(上下左右)的棋子可以移到空格中,该棋子原先位置成为空格.给出一个初始状态(保证可以转移…
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=26898 思路:我们可以给定有直接边相连的两点的距离为1,那么就是求源点出发能够走偶数步的所有的点的个数. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<queue> #include<vec…
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=26879 思路:题目意思很简单,就是通过一些位置的交换,最后变成有序数列,对于一组序列,我们可以用康托展开然后hash判重. 然后就是普通的bfs,稍微留意一下细节即可. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #incl…
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=26772 思路:注意判重就行,开个6维数组记录3个robots的位置,然后要注意的就是不能多个robots同时在一个格子上,一开始没注意到这点! #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<queue&…