hdu 4400 Mines(离散化+bfs+枚举)】的更多相关文章

Problem Description Terrorists put some mines in a crowded square recently. The police evacuate all people in time before any mine explodes. Now the police want all the mines be ignited. The police will take many operations to do the job. In each ope…
http://acm.hdu.edu.cn/showproblem.php?pid=4400 题意: 在笛卡尔坐标中有多个炸弹,每个炸弹有一个坐标值和一个爆炸范围.现在有多次操作,每次引爆一个炸弹,问每次操作会有多少个炸弹爆炸. 思路: 需要注意的是一个炸弹爆炸后会引起别的炸弹爆炸,然后别的炸弹爆炸后又会引起别的炸弹爆炸. 可以考虑bfs,但是必须需要优化,首先对x坐标进行离散化,然后将该坐标的y值和id值(第几个炸弹)存入multiset中,不同的x存入不同的multiset中.当我们进行寻找…
Coconuts Time Limit: 9000/4500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 524    Accepted Submission(s): 151 Problem Description TanBig, a friend of Mr. Frog, likes eating very much, so he always has dreams abou…
题目地址:HDU 1428 先用BFS+优先队列求出全部点到机房的最短距离.然后用记忆化搜索去搜. 代码例如以下: #include <iostream> #include <string.h> #include <math.h> #include <queue> #include <algorithm> #include <stdlib.h> #include <map> #include <set> #in…
题目传送门 /* 题意:问一个点到另一个点的最少转向次数. 坐标离散化+BFS:因为数据很大,先对坐标离散化后,三维(有方向的)BFS 关键理解坐标离散化,BFS部分可参考HDOJ_1728 */ #include <cstdio> #include <algorithm> #include <cstring> #include <queue> #include <vector> #include <map> #include <…
Mines Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1110    Accepted Submission(s): 280 Problem Description Terrorists put some mines in a crowded square recently. The police evacuate all peo…
3A的题目,第一次TLE,是因为一次BFS起点到终点状态太多爆掉了时间. 第二次WA,是因为没有枚举蛇的状态. 解体思路: 因为蛇的数目是小于5只的,那就首先枚举是否杀死每只蛇即可. 然后多次BFS,先从起点到第一把钥匙,不能往回走,要用VIS数组标记. 第二次从第一把钥匙走到第二把钥匙. 最后一次从最后一把钥匙走到终点即可. Tips 1: 在每次BFS过程中使用优先队列保证每次是最小步长的状态. Tips2 :使用二进制枚举蛇的状态 Tips3:首先使用DFS判断是否绝对有解,如果无解输出"…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5925 Coconuts Time Limit: 9000/4500 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others) 问题描述 TanBig, a friend of Mr. Frog, likes eating very much, so he always has dreams about eating. One day, Ta…
题目无法正常粘贴,地址:http://acm.hdu.edu.cn/showproblem.php?pid=5303 大意是给出一个环形公路,和它的长度,给出若干颗果树的位置以及树上的果子个数. 起点为0,背包大小为K,求最小走多少距离能摘完所有的果子并回到起点. 观察得知,公路长度L虽然上界10^9,但果子总和最多10^5,还是可做的. 显然如果想回家时在左半边肯定逆时针返回更近,在右边同理顺时针更近. 所有取果子的操作无非三种情况(顺时针出发逆时针返回&&逆时针出发顺时针返回&…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1043 题目大意:传统八数码问题 解题思路:就是从“12345678x”这个终点状态开始反向BFS,将各个状态记录下来,因为数字太大所以用康托展开将数字离散化. 代码: #include<iostream> #include<algorithm> #include<cstdio> #include<cstring> #include<string> #…