HDU 5045 Contest (状态压缩dp)

PSINS工具箱15状态组合导航仿真程序(test_SINS_GPS_153)浅析-卡尔曼滤波设置+导航解算 文章目录test_SINS_GPS_153源码poserrsetkfinitgabiaskfupdate流程 test_SINS_GPS_153源码 poserrset function poserr = poserrset(dpos0, dlon, dhgt) % position errors dpos=[dlat;dlon;dhgt] setting. % % Prototype: poserr = poserrset(dpos0) % Input: dpos0=[dlat; dlon; dhgt], 阅读详情

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5045


题面:

Contest

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1237    Accepted Submission(s): 494


Problem Description
In the ACM International Collegiate Programming Contest, each team consist of three students. And the teams are given 5 hours to solve between 8 and 12 programming problems.

On Mars, there is programming contest, too. Each team consist of N students. The teams are given M hours to solve M programming problems. Each team can use only one computer, but they can’t cooperate to solve a problem. At the beginning of the ith hour, they will get the ith programming problem. They must choose a student to solve this problem and others go out to have a rest. The chosen student will spend an hour time to program this problem. At the end of this hour, he must submit his program. This program is then run on test data and can’t modify any more.

Now, you have to help a team to find a strategy to maximize the expected number of correctly solved problems.

For each problem, each student has a certain probability that correct solve. If the i th student solve the j th problem, the probability of correct solve is P ij .

At any time, the different between any two students’ programming time is not more than 1 hour. For example, if there are 3 students and there are 5 problems. The strategy {1,2,3,1,2}, {1,3,2,2,3} or {2,1,3,3,1} are all legal. But {1,1,3,2,3},{3,1,3,1,2} and {1,2,3,1,1} are all illegal.

You should find a strategy to maximize the expected number of correctly solved problems, if you have know all probability
 

Input
The first line of the input is T (1 ≤ T ≤ 20), which stands for the number of test cases you need to solve.

The first line of each case contains two integers N ,M (1 ≤ N ≤ 10,1 ≤ M ≤ 1000),denoting the number of students and programming problem, respectively.

The next N lines, each lines contains M real numbers between 0 and 1 , the j th number in the i th line is P ij .
 

Output
For each test case, print a line “Case #t: ”(without quotes, t means the index of the test case) at the beginning. Then a single real number means the maximal expected number of correctly solved problems if this team follow the best strategy, to five digits after the decimal point. Look at the output for sample input for details.
 

Sample Input
  
1 2 3 0.6 0.3 0.4 0.3 0.7 0.9
 

Sample Output
  
Case #1: 2.20000
 

Source
2014 ACM/ICPC Asia Regional Shanghai Online

题目大意:
    给定n个人分别完成m个编程问题的成功率,问怎样分配可以使得最终期望的AC问题数最多。有一个限制,(每个人耗时1小时完成1道题)任意时刻,任何两个选手间的耗时数差不能超过1个小时。

解题:
    突破点在于耗时数差不能超过1个小时,我是没想到用01表示当前每个选手的答题数量减去一个基准值,如果想到了就很好写了。感觉状态压缩dp的精髓在于人为地筛选出一些合法的状态,减少盲目搜索,从而提高效率。

代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <set>
using namespace std;
int n,m,t;
//dp[i][j]表示第i位答题状态为j的最优值,posi存的是每个选手答每道题的正确概率
double dp[1010][1050],posi[11][1010];
int main()
{
	int tmp,lim;
	scanf("%d",&t);
	double ans,temp;
	for(int i=1;i<=t;i++)
	{
		//读入
		scanf("%d%d",&n,&m);
		memset(dp,0,sizeof(dp));
		for(int j=1;j<=n;j++)
			for(int k=1;k<=m;k++)
				scanf("%lf",&posi[j][k]);
		//两个set配合使用记录前一步合法状态
		set <int> s;
		set <int> ts;
		set <int> :: iterator it;
		//初始化
		for(int j=0;j<n;j++)
		{
			dp[1][1<<j]=posi[j+1][1];
			s.insert(1<<j);
		}
		for(int j=2;j<=m;j++)
		{
			ts.clear();
			//枚举前一步的合法状态
			for(it=s.begin();it!=s.end();it++)
			{
				for(int p=0;p<n;p++)
				{
					//如果前一步没取p的话,那么tmp值为0
					tmp=(1<<p)&(*it);
					if(!tmp)
					{
						//现在tmp为取了p之后的状态
						tmp=(*it)+(1<<p);
						//如果已经全部变成1了,那么清零
						if(tmp==(1<<n)-1)
						  tmp=0;
						//将此时的状态存入ts,同时排重,否则会超时
						ts.insert(tmp);
						//j位取p的值
                        temp=dp[j-1][*it]+posi[p+1][j];
						//优于原值,则更新
						if(temp>dp[j][tmp])
							dp[j][tmp]=temp;
					}
				}
			}
			//将ts的内容放入s
			s.clear();
			for(it=ts.begin();it!=ts.end();it++)
				s.insert(*it);
		}
		lim=(1<<n)-1;
		ans=0.0;
		//遍历最后一个位置的最优值
		for(int j=0;j<=lim;j++)
		{
			if(dp[m][j]>ans)
				ans=dp[m][j];
		}
		printf("Case #%d: %.5lf\n",i,ans);
	}
	return 0;
}



浅析图像处理中的名词:Gamma 校正(Gamma变换、Gamma调整) 阅读详情

相关推荐

我用 AI Agent 全自动跑 COMSOL 仿真:从建模到后处理,踩了 10+ 个深坑

本文探讨了利用AI通过COMSOL Java API实现AI芯片液冷冷板全流程自动化仿真的实践。针对700W高功耗AI芯片的散热需求,构建了包含4颗Chiplet和微通道冷板的三维液冷模型。通过严格设计的Prompt工程,AI Agent成功完成了从几何建模到结果验证的全过程,最终实现了芯片最高温度54°C的良好散热效果。文章重点分享了10个关键问题的解决经验,包括流体连通性验证、网格顺序控制、离散阶数选择、收敛判据优化等,并建立了包含流场/热场/网格独立性的三重验证体系。实践表明,AI可高效处理重复性工作

sjjsjjsjjsjjsjj的博客 1108

hdu 5045 Contest dp+状态压缩 2014 ACM/ICPC Asia Regional Shanghai Online

Contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 36    Accepted Submission(s): 9 Problem Description In the ACM Internationa

smz436487的专栏 682

抖音批量取消关注神器:5行JS代码搞定,告别手动操作(附详细步骤)

本文介绍了一种利用JS脚本在抖音创作者平台批量取消关注的高效方法。通过浏览器开发者工具执行简单的JavaScript代码,即可自动化模拟点击操作,快速清理大量关注列表,告别繁琐的手动操作。文中提供了详细的步骤和核心代码,适合有一定技术基础的用户参考。

weixin_29009971的博客 650

2019组队赛第二场(ACM International Collegiate Programming Contest, Arabella Collegiate 解题报告 Apare_xzc

2019组队赛第二场(ACM International Collegiate Programming Contest, Arabella Collegiate 解题报告 by xzc,zx,lj 先扔一个codeforces链接 vj链接:CCNUACM Team Contest 2019 Round #2 这次比赛我们队(zx,lj,xzc)出了8个题,还是挺好的 A. Multiplic...

Apare_xzc的博客 900

思博伦Spirent TestCenter创建单播流uni-stream

Traffic Generator列表中会出现刚才创建的uni-stream,创建完成。通常测试情况下,主要对Ethenet II和IPv4 Header进行配置。(通常情况下,如果流配置比较规范,选择任意端口接收,也没问题。编辑uni-stream基本信息。配置本条流由STC哪个端口接收。

辗转反测的博客 1688

2021秋招IC验证面经-ARM中国/中科芯/飞腾/地平线/中兴

中科芯 (央企福利待遇好,但是百分百不解决户口,适合当地人进去躺平。) 现场面试,三个面试官,时间大约40min 首先介绍一下自己,介绍一下项目。所做项目用到了FIFO吗,深度是多少,位宽是多少,仲裁算法是什么? 验证环境中的reference model是自己写的还是本身就有的,仲裁怎么在参考模型中实现,参考模型怎么获取寄存器的值? 怎么配置RTL寄存器,通过平台的寄存器模型进行寄存器配置,寄存器模型里边的方法,写一个寄存器或读一个寄存器怎么实现? 寄存器如何实现前门访问和后门访问,后门访问时

weixin_48014653的博客 6327

2019年4月2日训练(ACM International Collegiate Programming Contest, Amman Collegiate Programming Contest)

ACM International Collegiate Programming Contest, Amman Collegiate Programming Contest (2018) A B C D E F G H I J K L M ♠\spades♠ ♠\spades♠ ♠\spades♠ ♠\spades♠ ♣\clubs♣ Δ\DeltaΔ ⊕\oplus⊕ Δ\Del...

Dillonh的博客 690

基于微信小程序的垃圾分类系统,附源码

垃圾分类小程序管理员功能有个人中心,管理员管理,意见反馈管理,视频类型管理,垃圾类型管理,新闻类型管理,论坛信息管理,环保视频管理,环保知识管理,垃圾信息管理,环保新闻管理,用户管理,知识问答试卷管理,试题管理,测试管理,轮播图管理。用户可以在微信小程序上面注册登录,查看各种环保信息和垃圾信息,还可以参加知识问答等操作。垃圾分类小程序的开发根据操作人员需要设计的界面简洁美观,在功能模块布局上跟同类型网站保持一致,程序在实现基本要求功能时,也为数据信息面临的安全问题提供了一些实用的解决方案。

Java徐师兄的博客 2082

hdu5045 Contest ---- 状态DP

原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=5045 一:原题内容 Problem Description In the ACM International Collegiate Programming Contest, each team consist of three students. And the teams

半壶老酒 763

MAVEN教程-第一篇:MAVEN基础入门

MAVEN基础入门摘要 Maven是Java项目自动化构建工具,核心解决依赖管理(自动下载JAR包)、标准化构建流程(统一目录结构)和插件扩展问题。安装需配置环境变量(MAVEN_HOME),通过mvn -v验证。使用archetype:generate命令快速生成项目,标准结构包含src/main/java(主代码)和pom.xml(配置依赖/插件)。关键操作:mvn compile编译代码,mvn exec:java运行主类。POM文件定义项目元数据(如groupId)、依赖(如JUnit)和构建插件(

无 236

智能驾驶辅助系统(ADAS)全解析:功能详解 + 技术原理 + 实战案例

智能驾驶辅助系统(ADAS)是现代汽车技术的重要组成部分,旨在提升驾驶安全性和便利性。本文详细解析了ADAS的多个功能模块,包括自适应巡航控制(ACC)、车道偏离预警/车道保持辅助(LDW/LKA)、前向碰撞预警/自动紧急制动(FCW/AEB)、盲区检测/变道辅助(BSD/BSM)、倒车影像、自动泊车辅助(APA)、交通标志识别(TSR)、自动远光控制(AHB)、后方交叉来车预警(RCTA)和驾驶员疲劳监测。每个功能模块都基于特定的技术原理,如毫米波雷达、摄像头、传感器融合和深度学习算法,以实现对车辆周围环

weixin_43199439的博客 2128

HDU 5045 Contest

Contest Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged onHDU. Original ID:504564-bit integer IO format:%I64d Java class name:Main In the ACM Internat...

weixin_30726161的博客 155

100天精通Python(可视化篇)——第98天:Pyecharts绘制多种炫酷日历图参数说明+代码实战

一、日历图介绍 二、基础配置 1. 配置项类 2. 添加函数 3. 日期标签配置 4. 坐标系配置 三、日历图实战 1. 基础日历图 2. 日历热图

努力让自己发光,对的人才能迎着光而来 2万+

Hdu 5045 Contest (状态压缩dp)

Hdu 5045 Contest (状态压缩dp)  题意:有N个同学共同解决M道问题,每道题只能由一个同学来解决,每次花费一分钟,并且有成功率P,不能再次修改答案,任何时候不能任意两个同学做的题目数目不能相差超过1道题,有多种策略,求所有策略里最大成功期望是多少?     分析:最优化问题,用动态规划解决,由题意,每次做题时每个人都要轮到一次,然后状态清零,用二进制表示状态,即 0000

归去,也无风雨也无晴 307

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

hdu 5045 Contest 状态压缩dp

在任意时刻,任意两个人的答题时间不能超过1小时。换句话说,就是

Jane的私房菜 619

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

HDU 5045 Contest 状态压缩DP

题目描述:Description In the ACM International Collegiate Programming Contest, each team consist of three students. And the teams are given 5 hours to solve between 8 and 12 programming problems. On Mars,

喵头鹰的博客 404

HDU 5045 Contest DP+状态压缩

Contest Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/65536K (Java/Other) Total Submission(s) : 9   Accepted Submission(s) : 6 Font: Times New Roman | Verdana | Georgia Font

KeyboardPianist的博客 502

HDU-5045 Contest 状态压缩DP求期望

N个人,M道题,M个小时,每个人做一道题需要1个小时。给出一个N*M的矩阵代表每个人做对每道题的概率。然后要求在任何时刻,任意两个人的敲题时间差不能大于1,也就是说,m道题要分成多段长度为n的最优排列,n为10,2^10=1024 1024*1000  状压即可。 #include #include #include #include #include #include #inclu

聂小白的专栏 1066

HDU5045-Contest(DP+状态压缩)

题目链接 题意:有n个人做m道题目,每个人对于每题都有答对的概率,求最后答出所有题目概率的最大值。有要求就是每两个人之间答题的数目不能超过1。 思路:DP+状态压缩。dp[i][j]表示前i道题目j个人答题状态的最大值,j用二进制表示,因为人最多就10个。因为每两个人之间答题数目不能超过1,所以当状态达到1 代码: #include #include #inc

懒人一枚。 1233

hdu 5045 Contest(状态压缩DP)

题解:我们使用一个二位数组dp[i][j]记录进行到第i个任务时,人组合为j时的最大和(这里的j我们用二进制的每位对应一个人)。 具体见代码: #include #include #include #include using namespace std; typedef long long ll; double s[11][1010]; double dp[1010][105

浮躁的人,终究一事无成! 991

hdu - 5045 - Contest(状态压缩dp)

题意:N个人对M道题目都有自己通过的期望,每道题目要派一个人出战,任意两人出战次数不得超过1,求成绩的最大期望 (1 ≤ N ≤ 10,1 ≤ M ≤ 1000)。 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5045 ——>>设dp[i][j]表示已出战了前i - 1道题目,已出战的人的状态序列为j,现在要做第i道题目的最大期望,则最后要求的

无节操 1115

[ACM] hdu 5045 Contest (状态压缩Dp)

Contest Problem Description In the ACM International Collegiate Programming Contest, each team consist of three students. And the teams are given 5 hours to solve between 8 and 12 programming pr

逆风的方向 更适合飞翔 1813

Hdu 5045 Contest (2014 上海Online) (状态压缩dp)

听说还可以用二分图什么的gao

whyorwhnt的专栏 1304

HDU 5045 Contest(概率dp,状态压缩,2014上海网络赛1004)

题目:Contest 题意:这道题,感觉讲得有点难理解,bi

hongrock的专栏 734

2014上海网络赛1004||hdu5045 contest【状态压缩dp】

题意:m小时之间每个小时有新出的一个题供n个人中的一个人做,每个人做出的概率已知,每一时刻任意两个人做出的题数之差不得多于1个,问最多答题的个数 之前的状压都是三重循环是同一个数来的,然而这个题让我重新认识了状压QAQ 1.状压读数的话一定要从0开始啊啊啊,要不取状态值会很费劲的 2.做过状压都知道,第一重循环和第三重循环都是正常的数,第二重循环是状态。从“凑数”的角度看,第二重循环和第三重循环也得是n,第一重循环是m。从正常的解释来看,第一重循环推的是每个题,第二重循环是某人做过哪些题,第三重循环是

MissZhou要努力 474

<html>

题目链接:hdu 5045 Contest 题目大意:一个队伍有N个人。比赛一共同拥有M道题目,给定一个矩阵。表示每一个人答对对应题目的正确率。如今对于每道题。能够派出一名学生參加答题,可是在随意时刻,随意两个学生答题数量不能相差2题以上。 解题思路:dp[i][s],表示在第i道题,s表示一个二进制状态,表示哪些人答过题(对应的),2N−1...

weixin_33851604的博客 131
上一篇: HDU 2795 Billboard (线段树+想法)
下一篇: HDU 5050 Divided Land (二进制上的最大公约数)
David_Jett
博客等级 码龄12年 125粉丝 358原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值