HDU 3920 Clear all of them I

Mamba vs YOLO:目标检测选型指南(附实际项目对比) 本文深入对比了Mamba和YOLO在目标检测领域的性能差异与应用场景。通过实际项目数据,分析了两者在城市交通监控、工业质检等场景下的表现,提供了详细的选型指南和部署优化建议,帮助开发者根据实时性、精度等需求选择最适合的解决方案。 阅读详情
Clear All of Them I
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 122768/62768 K (Java/Others)
Total Submission(s): 722 Accepted Submission(s): 217


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


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

double dis[21][21];
double f[1 << 20];
int n;
struct LPoint{
	double x, y;
}point[21];

double Dist(LPoint a, LPoint b){
	return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}

double imin(double a, double b){
	return a < b ? a : b;
}

double dfs(int stat){
	int i, j, t;
	double k;
	if (!stat) return 0;
	if (f[stat] >= 0) return f[stat];
	
	t = stat;
	for (i = 0, k = 0x7fffffff; t; i++, t >>= 1){
		if (!(t & 1)) continue;
		t >>= 1;
		for (j = i + 1; t; j++, t >>= 1){
			if (!(t & 1)) continue;
			k = imin(k, dis[i + 1][j + 1] + imin(dis[0][i + 1], dis[0][j + 1]) + dfs(stat - (1 << i) - (1 << j)));
		}
		break;
	}
	return f[stat] = k;
}

int main(){
	int i, j, k, T;
	// freopen("A.in","r",stdin);
	// freopen("out.txt","w",stdout);
	scanf("%d", &T);
	for (k = 1; k <= T; k++){
		scanf("%lf %lf", &point[0].x, &point[0].y);
		scanf("%d", &n);
		for (i = 1; i <= n + n; i++)
			scanf("%lf %lf", &point[i].x, &point[i].y);
		for (i = 0; i <= n + n; i++)
			for (j = 0; j <= i; j++){
				if (i == j) dis[i][j] = 0;
				else dis[i][j] = dis[j][i] = Dist(point[i], point[j]);
			}
		for (i = 1; i < (1 << (n + n)); i++) f[i] = -1; 
		printf("Case #%d: %0.2lf\n", k, dfs((1 << (n + n)) - 1));
	}
	return 0;
}

/*************************
看到数据范围,可以用状态dp
f[s] 状态s的最小花费
f[s] = min{f[s - {i,j}] + cost(i,j)}
其中cost(i,j) = dis[i][j] + min(dis[0][i], dis[0][j]);
开始我真乖乖的枚举状态s中,最后射中的那俩数,果断超时...
后经范大哥讲解,只要枚举一个就好了,另一个随便取一个就行,不会丢情况。
可以这么想,随便取一个当最后射中的(射中顺序其实无所谓的,只是易于理解),此时只需枚举另一个和它一块射中的,就行了

总结:用递推的方法实现,总是TLE,换做记忆化搜索就快很多,想不太明白...
可能记忆化搜索把奇数个1的状态省去了
常数级差距在卡时时真让人郁闷= =
*************************/


农业生产AI决策系统架构设计解密:数据层-模型层-应用层核心逻辑 想象一下,在一个炎热的夏日,传统农田里的农民伯伯正满头大汗地检查每一株玉米是否缺水;而几公里外的智慧农场里,一位年轻农民正在空调房里滑动手机屏幕,看着AI系统自动生成的灌溉计划——这就是农业生产AI决策系统带来的改变。本文的目的,就是要揭开这个"智能农业大脑"的面纱,详细讲解它的"身体构造"(架构设计)和"工作原理"(核心逻辑)。我们将聚焦系统最核心的三个部分:数据层(收集农田信息)、模型层(分析信息并思考决策)和应用层(将决策告诉农民)。 阅读详情

相关推荐

实战教程:如何用Python+小波变换+CNN搞定医学影像中的条纹噪声(附完整代码)

本文提供了一套完整的实战方案,指导如何利用Python结合小波变换与卷积神经网络(CNN)去除医学影像中的条纹噪声。该方法通过小波变换精准定位噪声,再使用轻量化CNN进行针对性清除,有效保护图像细节,并附有可运行的完整代码,为医学影像处理与AI分析提供高效工具。

weixin_29056101的博客 269

hdu 3920 Clear All of Them I

状态压缩DP 主要是由于每次从最右边的1开始找,所以一般的正推可能会导致产生很多冗余状态 记忆话搜索的话会好不少 #include #include #include #include using namespace std; int n; struct P

hqd_acm的专栏 791

从零到一:手把手教你用DaVinci Configurator配置一个完整的AUTOSAR接口通信实例

本文详细介绍了如何使用DaVinci Configurator工具配置AUTOSAR接口通信实例,从环境准备到SWC端口定义、BSW模块配置,再到通信验证的全过程。通过实战案例'车窗控制'功能模块,帮助开发者快速掌握AUTOSAR架构下的接口通信配置技巧,提升汽车电子软件开发效率。

weixin_42557830的博客 451

hdu3920 Clear All of Them I

Clear All of Them I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 122768/62768 K (Java/Others) Total Submission(s): 1194    Accepted Submission(s): 389 Problem Description Acmers

喵呜的Blog 865

Linear超高PSRR线性稳压器-典型应用电路解析

本文整理完了LT3045数据手册内所有的典型应用电路,试图让沉默的电路开口,简单介绍了他们这样做的目的和原理,从中我们可以更加熟悉这颗经典芯片的应用。但也有一些电路并没有搞懂,遗留下了不少问题。

硬件工程师笔记 2942

手把手教你用FPGA驱动DAC8830:一个Verilog SPI驱动模块的完整实现与调试

本文详细介绍了如何使用FPGA通过Verilog实现DAC8830的SPI驱动模块,包括SPI通信机制解析、Verilog模块设计、代码优化及调试技巧。重点解决时钟同步、状态机设计等工程实践问题,适用于音频处理、仪器仪表等高精度数模转换场景。

weixin_26886855的博客 230

HDU 3920 Clear All of Them I 状压DP

Clear All of Them I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 122768/62768 K (Java/Others) Total Submission(s): 1681    Accepted Submission(s): 544 Problem Description Acmers

wust_ZJX的专栏 959

CentOS校园网Web Portal认证自动化实战

Web Portal认证是一种基于HTTP重定向与表单提交的强制网络准入机制,其原理是网关劫持未认证流量并跳转至登录页,验证通过后通过Cookie维持会话授权。该技术广泛应用于高校、机场、酒店等场景,核心价值在于细粒度访问控制与用户身份绑定。典型应用包括Linux命令行环境下的校园网接入、无GUI设备的自动联网、以及实验室集群的集中认证管理。本文聚焦CentOS系统,深入解析curl、cookie持久化、动态表单参数提取等关键技术环节,提供可调试、可复现、可工程化的完整认证流水线。

weixin_30522983的博客 265

hdu 3920 Clear All of Them I 状态压缩 动态规划

hdoj 3920 http://acm.hdu.edu.cn/showproblem.php?pid=3920        刚拿这道题同学告诉我能费用流 然后我看了他建图 然后我就推翻了他的图......    看到此题数据n==10  20个点 瞬间想到2^20==

123```` 943

用CentOS 7安装cadence搭建适合IC Design的科研环境(四)——IC617、MMSIM151、calibre2015安装过程step by step

以下操作都在root权限下执行。建立安装目录建议把这种大型软件装在/opt目录下。mkdir -p /opt/cadence/installscape mkdir -p /opt/mentor/Calibre2015其中-p参数是直接建立父目录。因为IC617和MMISM151会自己建立安装目录,所以在这里没有建相关目录。而calibre则是默认安装在安装包所在的目录下,所以需要提前建立。解压安

maxwell2ic的博客 7万+

从零开始学 PyTorch 7天路线图(完整可运行代码版)

本文提供了5天PyTorch入门教程的完整代码,涵盖从基础到实战的核心内容。Day1测试环境并介绍张量基础;Day2讲解常用张量操作;Day3演示自动求导机制;Day4实现完整线性回归模型;Day5构建MNIST手写数字识别全连接网络。所有代码可直接运行,包含GPU检测、梯度计算、模型训练和可视化等关键环节,帮助新手快速掌握PyTorch核心概念和典型应用场景。

IT老农民的博客 314

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

HDU 3920 Clear All of Them I 题目是说有2n个敌人,现在可以发n枚炮弹,每枚炮弹可以(可以且仅可以)打两个敌人,每一枚炮弹的花费等于它所行进的距离,现在要消灭所有的敌人,问最少花费是多少(反正题意大概就是这样啦,知道怎么回事就好了,解释不清了) 一看到n<=10而且又是在DP专题里的,就知道这个显然是状压DP,由于有2n个敌人,所以状态表示由当前状态再打两...

weixin_34128839的博客 151

git clone出现fatal: unable to access Failed to connect to github.com port 443: Timed out解决方案

本文主要介绍了git clone出现fatal: unable to access Failed to connect to github.com port 443: Timed out解决方案,希望能对使用git的同学们有所帮助。 文章目录 1. 问题描述 2. 解决方案

weixin_43178406的博客 23万+

HDU 3920 Clear All of Them I(状态压缩)

https://blog.youkuaiyun.com/lxglbk/article/details/6674270 #include &lt;iostream&gt; #include &lt;cstdio&gt; #include &lt;cstring&gt; #include &lt;algorithm&gt; #include &lt;cmath&gt; using namespace std...

ccshijtgc的专栏 203

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

HDU 3920 Clear All of Them I(状压DP)题解

题意:2n个点,一个起点,开n枪,每枪必须打两个点,花费为起点到其中一点距离加上两点距离。问打完2n个点的最小花费。 思路:很显然应该dp状态,然后枚举i j两个空位置去填,那么复杂度$O(20 * 20 * n^{20})$,这个会超时。因为内存限制不能预处理每个状态的子状态。所以我们要想办法减少复杂度。显然复杂度多在重复枚举的过程,因为花费之和与枚举的顺序无关,即我用(a,b)(c,d)还是...

weixin_33935505的博客 151

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

hdu 3920 Clear All of Them I 状态压缩DP

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.

kongming_acm的专栏 678

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

HDU3920:Clear All of Them I(状态压缩)

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 a

ACM!荣耀之路! 1500

HDU--3920[Clear All of Them I] 状态压缩DP或模拟退火

PS、正解貌似是状态压缩DP,DP依旧不会、感觉和售货员问题差不多,于是试了下模拟退火居然还真水过去了= =!   后然用状态压缩DP也写了一次、、、、、   CODE(1):模拟退火 /*模拟退火*/ /*AC代码:890ms*/ #include #in

___简言 1056

hdu 3920 Clear All of Them I (状态压缩DP)

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 a

hndu__lz的博客 316

Clear All of Them I(HDU 3920状压dp)

题意:给有2*n个敌人的位置,枪在(0,0)位置,一次能消灭两个敌人,耗费能量为枪到一个敌人,由这个敌人再到另个敌人的的距离和,求消灭所有敌人最小耗费能量。 分析:一次枚举状态的两位即可 #include <map> #include <set> #include <list> #include <cmath> #include &l...

weixin_30386713的博客 95

HDU 3920 Clear All of Them I(DP + 状态压缩 + 贪心)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3920 题目大意:你在一个位置用激光枪灭敌人,给你初始位置,下面是2*n个敌人的位置,你一枪能杀两个,可以杀死任意两个人,激光束的路径是消耗的能量,求最小能量,保证一次只消灭两个敌人,你的位置不变 Sample Input 2 0 0 1 6 0 3 0 ...

weixin_30856965的博客 148

HDU 3920 Clear All of Them I 状态压缩DP 2011 Multi-University Training Contest 9 - Host by BJTU

/* 参考:http://blog.youkuaiyun.com/racebug2010/article/details/6683963 第一道状态压缩DP state的二进制表示(如110011)表示状态第1,2,5,6的点已经被消灭 DP[state]表示为state状态时的最小距离和

Join Hands 808

HDU 3920 Clear all of them (状态压缩+记忆化搜索)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3920 #include &lt;algorithm&gt; #include &lt;iostream&gt; #include&lt;cmath&gt; #include&lt;cstring&gt; #include&lt;stdio.h&gt; #define maxn 30 #define...

满月照亮的路 207

HDU 3709 Balanced Number

Balanced Number Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others) Total Submission(s): 162 Accepted Submission(s): 59 Problem Description A balanced number is a

cmonkey 2287

codeforce 55D Beautiful numbers

D. Beautiful numbers time limit per test:4 seconds memory limit per test:256 megabytes input:standard input output:standard output Volodya is an odd boy and his taste is strange as well. It see

cmonkey 2177
上一篇: HDU 3913 Suffix
下一篇: POJ 2635 The Embarrassed Cryptographer
cmonkey
博客等级 码龄17年 50粉丝 47原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值