Clear All of Them I

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 122768/62768 K (Java/Others)
Total Submission(s): 1455    Accepted Submission(s): 484

Problem Description
Acmers have been the Earth Protector against the evil enemy for a long time, now it’s your turn to protect our home.
  There are 2 * n enemies in the map. Your task is to clear all of them with your super laser gun at the fixed position (x, y).
  For
each laser shot, your laser beam can reflect 1 times (must be 1 times),
which means it can kill 2 enemies at one time. And the energy this shot
costs is the total length of the laser path.
  For example, if you
are at (0, 0), and use one laser shot kills the 2 enemies in the order
of (3, 4), (6, 0), then the energy this shot costs is 5.0 + 5.0 = 10.
00.
  Since there are 2 * n enemies, you have to shot n times to
clear all of them. For each shot, it is you that select two existed
enemies and decide the reflect order.
  Now, telling you your
position and the 2n enemies’ position, to save the energy, can you tell
me how much energy you need at least to clear all of them?
  Note that:
   > Each enemy can only be attacked once.
   > All the positions will be unique.
   > You must attack 2 different enemies in one shot.
   > You can’t change your position.
 
Input
The first line contains a single positive integer T( T <= 100 ), indicates the number of test cases.
For each case:
  There are 2 integers x and y in the first line, which means your position.
  The second line is an integer n(1 <= n <= 10), denote there are 2n enemies.
  Then there following 2n lines, each line have 2 integers denote the position of an enemy.
  
  All the position integers are between -1000 and 1000.
 
Output
For
each test case: output the case number as shown and then print a
decimal v, which is the energy you need at least to clear all of them
(round to 2 decimal places).
 
Sample Input
2

0 0
1
6 0
3 0

0 0
2
1 0
2 1
-1 0
-2 0

 
Sample Output
Case #1: 6.00
Case #2: 4.41
 
Source
 
 
网上给这道题的定义为状压DP优化,但我实在看不出哪儿有优化的意义,然后,我就TLE了。

HDUOJ Clear All of Them I 状压DP的更多相关文章

  1. CF453B Little Pony and Harmony Chest (状压DP)

    CF453B CF454D Codeforces Round #259 (Div. 2) D Codeforces Round #259 (Div. 1) B D. Little Pony and H ...

  2. loj 1316(spfa预处理+状压dp)

    题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=27024 题意:求0-(n-1)的经过最多的标记的点的最短路. 思路 ...

  3. HDU 3920Clear All of Them I(状压DP)

    HDU 3920   Clear All of Them I 题目是说有2n个敌人,现在可以发n枚炮弹,每枚炮弹可以(可以且仅可以)打两个敌人,每一枚炮弹的花费等于它所行进的距离,现在要消灭所有的敌人 ...

  4. hdu 4739 状压DP

    这里有状态压缩DP的好博文 题目:题目比较神,自己看题目吧 分析: 大概有两种思路: 1.dfs,判断正方形的话可以通过枚举对角线,大概每次减少4个三角形,加上一些小剪枝的话可以过. 2.状压DP,先 ...

  5. [BZOJ 1072] [SCOI2007] 排列perm 【状压DP】

    题目链接:BZOJ 1072 这道题使用 C++ STL 的 next_permutation() 函数直接暴力就可以AC .(使用 Set 判断是否重复) 代码如下: #include <io ...

  6. BZOJ 3446: [Usaco2014 Feb]Cow Decathlon( 状压dp )

    水状压dp. dp(x, s) = max{ dp( x - 1, s - {h} ) } + 奖励(假如拿到的) (h∈s). 时间复杂度O(n * 2^n) ------------------- ...

  7. 【XSY2745】装饰地板 状压DP 特征多项式

    题目大意 你有\(s_1\)种\(1\times 2\)的地砖,\(s_2\)种\(2\times 1\)的地砖. 记铺满\(m\times n\)的地板的方案数为\(f(m,n)\). 给你\(m, ...

  8. 【BZOJ4042】【CERC2014】parades 状压DP

    题目大意 给你一棵\(n\)个点的树和\(m\)条路径要求你找出最多的路径,使得这些路径不共边.特别的,每个点的度数\(\leq 10\). \(n\leq 1000,m\leq \frac{n(n- ...

  9. bzoj2004 矩阵快速幂优化状压dp

    https://www.lydsy.com/JudgeOnline/problem.php?id=2004 以前只会状压dp和矩阵快速幂dp,没想到一道题还能组合起来一起用,算法竞赛真是奥妙重重 小Z ...

随机推荐

  1. [Redux] Filtering Redux State with React Router Params

    We will learn how adding React Router shifts the balance of responsibilities, and how the components ...

  2. 导入一个AndroidStudio工程作为一个Library Module

    尊重劳动成果,转载请注明出处:http://blog.csdn.net/growth58/article/details/47441245 关注新浪微博:@于卫国 邮箱:yuweiguocn@gmai ...

  3. The Class Loader Hierarchy--转载

    Class loaders in the Application Server runtime follow a delegation hierarchy that is illustrated in ...

  4. Android(java)学习笔记189:eclipse 导入项目是提示:某些项目因位于工作空间目录中而被隐藏。

    导致这个错误的原因是工程重名了: 并不是仅仅指文件夹重名,相信很多人也曾经修改过文件夹的名称,可惜没什么用处,关键是修改工程里面的一个文件!也就是.project这个文件! 用记事本打开,修改一下&l ...

  5. python实时处理log文件脚本

    这个Python脚本是用来对实时文件的内容监控,比如 Error 或者 time out 字段都可以进行自定义:算是我的第一个真正的Python脚本,自己感觉还是比较臃肿,不过打算放到blog上记录一 ...

  6. 微信上传图文消息素材40007,invalid media_id hint

    上传图文消息素材40007,invalid media_id hint,微信40007 >>>>>>>>>>>>>> ...

  7. jar打包通过exe4j转换成exe文件

    去年的时候有用过,最近写java的时候偶然用到,mark一下,方便以后看 下载链接后面附上 首先我们在eclipse上打包成jar文件,我这里只把简单的截图贴出来,详细的可以自行百度 打包jar文件: ...

  8. [DEncrypt] DESEncrypt--加密/解密帮助类 (转载)

    点击下载 DESEncrypt.zip 这个类是关于加密,解密的操作,文件的一些高级操作1.DESEncrypt加密2.DESEncrypt解密看下面代码吧 /// <summary> / ...

  9. StarUML启动时候出现"System Error. Code:1722. RPC服务器不可用."错误的解决办法

    StarUML是用得很顺手的UML工具,但是启动时候每次都会出现"System Error. Code:1722. RPC服务器不可用."错误. 一般来说这个应该是某个Window ...

  10. What's DB2 模式?

    近期负责一个银行方面的项目,需要用到DB2实现多数据库版本切换.初步接触DB2,对于它的管理工具(IBM DATA STUDIO)虽然与ORACLE\MSSQL大同小异,但还是有些东西不一样的.比如什 ...