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. 分享2D Unity游戏的动画制作经验

    作者:Alex Rose Unity近期宣布推出额外的2D游戏支持,加入了Box 2D物理和一个精灵管理器. 但这里还是有些技巧须要牢记在心.逐帧更改图像仅仅是动画制作的冰山一角,若要让你的游戏出色执 ...

  2. DTrace Probes in HotSpot VM----java

    http://docs.oracle.com/javase/6/docs/technotes/guides/vm/dtrace.html http://docs.oracle.com/javase/7 ...

  3. GCC扩展(转--对看kernel代码有帮助

    http://my.oschina.net/senmole/blog?catalog=153878 Linux Kernel的代码,上次就发现一个结构体的定义形式看不懂,后来才知道它用的不是标准的AN ...

  4. android UI生成器

    可根据选择的效果生成资源 http://jgilfelt.github.io/android-actionbarstylegenerator/#name=example&compat=sher ...

  5. android开发之SwipeListView的使用

    实现一种类似于qq中滑动列表的功能: 向左或者向右滑动,然后执行相关操作. 这里用到的是GitHub上的开源控件SwipeListView,下载地址https://github.com/47deg/a ...

  6. Android 自定义View修炼-自定义HorizontalScrollView视图实现仿ViewPager效果

    开发过程中,需要达到 HorizontalScrollView和ViewPager的效果,于是直接重写了HorizontalScrollView来达到实现ViewPager的效果. 实际效果图如下: ...

  7. Android(java)学习笔记196:Android中Menu的使用(静态和动态)

    1.使用xml定义Menu(静态方法) 菜单资源文件必须放在res/menu目录中.菜单资源文件必须使用<menu>标签作为根节点.除了<menu>标签外,还有另外两个标签用于 ...

  8. Android(java)学习笔记188:关于构造代码块,构造函数的一道面试题(华为面试题)

    1.源码是: package text; public class TestStaticCon { public static int a = 0; static { a = 10; System.o ...

  9. HDU-1012(水题)

    http://acm.hdu.edu.cn/showproblem.php?pid=1012 分析:就按题目给的公式一步步输出就行了. #include<stdio.h> #include ...

  10. exists查询中子表可以是

    exists查询中子表可以是’或则具体某一列 ,查询结果一致,因为exists只会返回 true或者false,一个boolean型的值