摘要: 贴几道bfs题。题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2216思路:用一个四维的数组来保存状态,然后就是一般的bfs了,不过要注意的S,Z的初始位置要置为'.'(这个地方debug了好久,orz...).View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 #include<queue> 6 using namespace std; 7 # 阅读全文
posted @ 2013-05-14 23:51 ihge2k 阅读(251) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1538题意:最短路问题,但是要求出最短路的条数,同时要求出所有可能的最短路选择中javabean最多的情况。思路:求到终点的最短路径用Dijkstra,其路径更新条件(如果到某个点有多个路径长度一样的最短路径,则选择豆子总数最多的)就是直接加个else if条件就搞定了,最后就是dfs搜一下最短路的条数了,这个我就记忆化了一下。然后我一开始使用spfa写的,wa了好多次,orz...改成dijkstra就过了。 1 #include<iostream> 阅读全文
posted @ 2013-05-14 21:53 ihge2k 阅读(309) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1067思路:学会了手写Hash。。。orz....纪念一下。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 #include<queue> 6 using namespace std; 7 #define MAXN 1000007 8 typedef long long ll; 9 ll Hash[MAXN]; 10 11 st 阅读全文
posted @ 2013-05-14 16:44 ihge2k 阅读(708) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2438网上大牛思路:可以根据边界,汽车已经转弯,设水平方向为x轴,垂直方向为y轴。则汽车的内边界(靠近里面的边界)的直线方程式f(x)为:y=x*tan(a)+l*sin(a)+d/cos(a).其中a是汽车与x轴的夹角当y=X时,求解出的-x即为汽车的内边界到y轴的距离h,若h小于Y即可转弯,若大于Y就不能转弯。所以只需要利用方程式,求-x的最大值,即可判断能否通过。由于f(x)是凸函数(随着x的增大y先增大后减小),所以,需要借助三分求解。图示:第一道三分求极值题啊!!! 1 #include 阅读全文
posted @ 2013-05-14 12:30 ihge2k 阅读(1333) 评论(0) 推荐(0) 编辑