hdu 3309 Roll The Cube ( bfs )】的更多相关文章

Roll The Cube Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 345    Accepted Submission(s): 127 Problem Description This is a simple game.The goal of the game is to roll two balls to two holes…
Rubik's Cube 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5836 Description As we all know, Zhu is the wisest man. When Liao was ninety-nine years old, the Zhu appeared to him and said, "I am God Almighty; walk before me and be blameless. I will co…
BFS,考虑一球进洞仅一球滚动以及两球重叠的情况即可. /* 3309 */ #include <iostream> #include <queue> #include <cstdio> #include <cstring> #include <cstdlib> using namespace std; #define MAXN 25 typedef struct { ], y[]; ]; int t; } node_t; int n, m; n…
HDU 2717 题目大意:在x坐标上,农夫在n,牛在k.农夫每次可以移动到n-1, n+1, n*2的点.求最少到达k的步数. 思路:从起点开始,分别按x-1,x+1,2*x三个方向进行BFS,最先找到的一定是最小的步数. /* HDU 2717 Catch That Cow --- BFS */ #include <cstdio> #include <cstring> #include <queue> using namespace std; ]; int n, k…
1.HDU 5876  Sparse Graph 2.总结:好题,把STL都过了一遍 题意:n个点组成的完全图,删去m条边,求点s到其余n-1个点的最短距离. 思路:把点分为两个集合,A为所有没有到达过的点,B为当前不可到达的点,每次拓展A中可到过的点加入队列. #include<iostream> #include<cstring> #include<cmath> #include<queue> #include<algorithm> #inc…
Asteroids! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3159    Accepted Submission(s): 2106 Problem Description You're in space.You want to get home.There are asteroids.You don't want to hit…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1175 越学越不会,BFS还是很高级的. 连连看 Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 30994    Accepted Submission(s): 7694 Problem Description “连 连看”相…
http://acm.hdu.edu.cn/showproblem.php?pid=3085 出的很好的双向bfs,卡时间,普通的bfs会超时 题意方面: 1. 可停留 2. ghost无视墙壁 3. 需要检查两次某个地点是否有ghost,正要到达的时候(t),以及即将启程的时候(t+1). 在编程时需要注意的是: 当两个人汇合时,不需要检查即将启程的那次. M可以走3步,在这3步中间只需要检查是否能到达(t) 出问题在: 1. 检查时间处理的不清晰 2.普通bfs会超时 3.双向bfs需要完全…
http://acm.hdu.edu.cn/showproblem.php?pid=1240 开始没仔细看题,看懂了发现就是一个裸的bfs,注意坐标是三维的,然后每次可以扩展出6个方向. 第一维代表在第几层.后两维代表行和列. #include <cstdio> #include <cstring> #include <queue> using namespace std; struct point { int x,y,z,step; bool operator <…
http://acm.hdu.edu.cn/showproblem.php?pid=1180 注意点就是楼梯是在harry移动完之后才会改变方向,那么只要统计到达这个点时间奇偶性,就可以知道当前楼梯是水平的还是垂直的. 并且我们需要知道当前到达楼梯这个点的方向,这样才知道下一个往哪个方向走,可以根据dir数组来判断方向. 楼梯不用判重. #include<stdio.h> #include<string.h> #include<queue> #include<io…