HDU5045 状压dp

Coze:手把手教你搭建 小红书二创 智能体 前一篇 “” ,讲了如何针对需求进行拆解,并拆解 ”小红书二创“ 智能体,分为四个内容模块。通过上述步骤,开始一步一步构建 “小红书二创” 智能体。用来测试的小红书地址:http://xhslink.com/a/quxWEDAj3J48。 阅读详情

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 ith student solve the jth problem, the probability of correct solve is Pij .

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 jth number in the ith line is Pij .

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

讲道理一开始做看错题连思路都想不到…菜到死
后来想到了怎么做但是真的蠢到炸
因为没办法记录状态我竟然想到每过一个m记录一遍状态………………………
蠢死了…………………………….
看别人的博客才想起来状压的正规路子…..
应该是从已有的状态转移…
没被转移的continue……..

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<memory.h>
using namespace std;
double tu[15][2050];
double dp[1 << 11][2000];
int main()
{
    int T, n, m, u = 0;
    cin >> T;
    while (T--)
    {
        cin >> n >> m;
        for (int a = 0;a < n;a++)for (int b = 0;b < m;b++)scanf("%lf", &tu[a][b]);
        for (int a = 0;a <= m;a++)for (int b = 0;b <= (1<<n);b++)dp[a][b] = -1;
        double sum = 0;
        dp[0][0] = 0;
        for (int a = 0;a < m;a++)
        {
            for (int c = 0;c < (1 << n);c++)
            {
                if (dp[a][c] <0)continue;
                for (int b = 0;b < n;b++)
                {
                    int zong = 1 << b;
                    if (zong&c)continue;
                    if((zong|c)!=(1<<n)-1)dp[a+1][zong | c] = max(dp[a+1][zong | c], dp[a][c] + tu[b][a]);
                    else dp[a+1][0] = max(dp[a+1][0], dp[a][c] + tu[b][a]);
                }
            }
        }
        for (int a = 0;a < (1 << n);a++)sum = max(sum, dp[m][a]);
        printf("Case #%d: %.5lf\n", ++u, sum);
    }
    return 0;
}
ICCompiler II实战:从NDM生成到APR流程的完整避坑指南 本文是一份针对ICCompiler II(ICC II)后端物理实现流程的实战避坑指南。文章详细解析了从NDM库生成、设计初始化、布局规划到时钟树综合与布线的完整APR流程,重点分享了各环节的常见陷阱、精细化配置命令与调试经验,旨在帮助工程师高效达成PPA目标,确保设计一次成功。 阅读详情

相关推荐

【高等数值分析】Krylov子空间方法

文章目录1. 预备理论1.1 Krylov 子空间1.2 最佳逼近1.2.1 方法一:最佳平方逼近1.2.2 方法二:假设 AAA 对称正定1.2.3 方法三:残差2范数2. 基底正交化2.1 Arnoldi 过程(CGS)2.2 改进 Arnoldi 过程(MGS)2.3 Lanczos过程3. 方程组求解3.1 全正交方法 (FOM)3.2 D-Lanczos方法3.3 广义极小残量法(GMRES)3.4 MINRES 方法 1. 预备理论 现在需要求解一个大规模稀疏方程组 Ax=bAx=bAx=b,可

Glooow的博客 1万+

Hdu--5045(状态压缩DP)

2014-09-2801:40:20 思路:根据题目的意思,考虑到:只有所有的人的编程时间达到某个值(如k)后才能有一个人的编程时间达到k+1,所以就是对于每n个连续问题的人员指派是1,2...n的一种排列。 考虑到人数少,直接状压,用dp[i][j]来表示考虑第 i 个问题时,状态为 j 时的最优解,j 是一个二进制数,它的第 p 位为0说明第 p+1 个人当前还没被指派做题。(...

dingdi3021的博客 196

电子元器件基础:电阻、电容、电感的特性与应用解析

本文深入解析了电子元器件中电阻、电容和电感三大基础元件的核心特性、工作原理与选型应用。电阻作为电路中的‘交通警察’,控制电流与分配电压,其额定功率与精度是关键选型参数。文章结合实战经验,详细阐述了它们在电源滤波、信号处理及高频电路中的不同表现与避坑指南,是电子设计与维修的必备基础知识。

weixin_29213655的博客 386

hdu----(5045)Contest(数位dp)

Contest Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 220Accepted Submission(s): 88 Problem Description In the ACM International C...

weixin_30556959的博客 86

Flowable高级篇 -6.8.0 最全表结构说明-主要表结构字段注释

flowable 28张表 详细

billzhen的博客 1万+

用Multisim仿真AD630锁定放大器:从2012年电赛A题实战到避坑指南

本文详细介绍了如何使用Multisim仿真AD630锁定放大器,从2012年电赛A题实战出发,提供完整的电路搭建、参数优化及避坑指南。重点解析AD630的开关调制架构和双相位检测的工程实现,帮助读者在强噪声背景下有效提取微弱信号,提升电子设计竞赛和工程实践中的信号处理能力。

weixin_42549451的博客 207

hdu 5045(状态压缩dp)

题目链接: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): 348    Accepted Submission(s):

T_T 742

保姆级教程:在紫光同创Titan2 FPGA上实现PCIe DMA,实测带宽接近理论极限

本文详细介绍了在紫光同创Titan2 FPGA上实现PCIe DMA性能调优的全过程,通过参数优化和架构设计,实测带宽达到6.91GB/s,接近理论极限。涵盖开发环境搭建、PCIe IP核定制、DMA引擎设计、驱动开发及性能调优等关键步骤,为FPGA开发者提供实用指南。

weixin_30954817的博客 347

hdu5045 Contest(费用流)

这个题目刚开始看没思路,听别人说是费用流,打死也没看出来,后来发现自己傻了,确实很简单,这个题是说n个人,m道题,然后每答完一道题,任意两个人答题的数目的差不能大于1,所以比如说4个人,10个题,那么一定是,前四个题目每人一个,5到8题没人一个,后两个随机,但也必须每人最多做一个,这样的话其实就是跑了m/n+1次费用流,因为要以费用跑最短路,所以要把费用变成其相反数来做,还有就是注意是浮点数,不能硬

银之夏雪的博客 443

从SIGGRAPH审稿人视角看:什么样的TOG论文更容易被接收?

本文从SIGGRAPH审稿人视角深入解析TOG论文的审稿标准与投稿策略,揭示如何提升论文接收概率。重点探讨创新性、技术深度、实验验证等核心评分维度,并提供写作技巧与审稿意见应对策略,帮助研究者优化ACM Transactions on Graphics投稿质量。

weixin_33721344的博客 112

Python反爬实战|动态渲染+高可用IP代理集群,稳定爬取京东/淘宝10万+商品数据

做Python电商爬虫的同学,应该都对京东、淘宝的反爬机制深有体会——这两个平台的反爬体系,堪称国内网站的天花板,远比普通资讯、政务网站的反爬严格十倍不止。用requests库请求商品列表,返回的永远是只有骨架的空HTML,商品标题、价格、销量全是前端JS异步加载,抓包分析接口发现参数全是加密的signtoken,解密成本无限高;用selenium开无头浏览器爬取,刚爬3-5页就触发风控,页面直接返回403,IP被封禁,甚至连Cookie都直接失效;

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 1589

hdu5045(状态压缩dp)

链接:点击打开链接 题意:有n个人做m道题目,给出每个人对每道题答对的概率,求最后答出所有题目概率的最大值。要求每两个人之间答题的数目不能超过1 代码: #include #include #include #include #include #include #include using namespace std; double s[20][2005],dp

stay_accept的专栏 612

Dify智能体开发:大语言模型(LLM)问题分类

通过定义分类描述,问题分类器能够根据用户输入,使用 LLM 推理与之相匹配的分类并输出分类结果,向下游节点提供更加精确的信息。

王国平的博客 2260

HDU 5045 DP+状压

2014 ACM/ICPC Asia Regional Shanghai Online 给出N个人做M道题的正确率,每道题仅仅能由一个人做出,而且当全部人都做出来且仅做出一道题时,做过题的人才干够继续做题,求最大期望。 一共仅仅有10个人,状压存储每一个人是否已经做出题目,假设都作出则状态清0。 #include "stdio.h" #include "stri...

diandingyin9417的博客 73

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

[状压dp]HDU5045 Contest

题意: n和人做m道题, 每俩人做的题数不能相差一题以上.(也就是每n道题分别由n个人完成) 给n个人分别做m道题的概率, 求完成m题的最大期望 $1\le N \le 10$ 注意!!! fill dp 的地方! [0, m] 所以要 m+1 !! 1 #include <cstdio> 2 #include <cstdlib> ...

aicheng4794的博客 129

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

hdu 5045 状压dp

因为所有人做题数量差不能大于1 所以可以把每n道题看成一组 每一组必须由每个人完成一道的方式完成 dp[i][j] i代表当前题数 j代表当前队员状态 #include #include #include using namespace std; double dp[1005][1050],r[11][1005],ans,tmp; int T,n,m,i,j,first,t,k,MAX,kas

a709743744的博客 286

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

hdu 5045 Contest (状压DP)

状压dp,将m道题分段,每段有ndao

FirstorLoser 412

hdu5045 Contest 状压DP

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

EventQueue的博客 544

【DP】 HDU 5045 Contest 状压

必须按照循序写题 所以要给dp数组赋初值-1 每取满n个时要注意要使得now为零 以便下次取 #include #include #include #include #include #include #include #include using namespace std; #include #include #include #include #include

Kewowlo 1378

HDU 5045 Contest(状压DP或费用流)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5045 题意:N个人去做M道题,给出这N个人解这M道题的概率,且任意两人做题数不能相差1,问做出所有题的最大期望 思路:因为做题数不超过1的限制,这相当于是以N个人为一轮做N道题,做完M道为止,故而可以用dp[i][j]代表解决前i道题时状态为j,当j == (1 << n)...

Tongqi 538

hdu5045 Contest 状压dp/KM

链接: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): 260    Accepted Submission(s): 1

833

HDU 5045 状压DP 上海网赛

比赛的时候想的是把n个n个的题目进行状压 但这样不能讲究顺序,当时精神面貌也不好,真是挫死了 其实此题的另一个角度就是一个n个数的排列,如果我对n个人进行状压,外面套一个按题目循序渐进的大循环,那么,在当前做第i个题目,前i-1个题目已经做完,然后做完的人的状态为j, j可能是1110 1101 1011什么的(假设已经做了三道题),因为我这样就可以只管状态而不管顺序了,我只取这种状态...

weixin_30393907的博客 87

HDU-5045 Contest(状压DP)

HDU-5045 Contest 一、题目原文 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.

Summer_via的博客 420

HDU5045-Contest(状压dp)

题意: 有n个学生,m道题,给出每个同学解出m个问题的概率,在解题过程中每个学生的解题数的差不大于1,求最大能解出题目数的期望 分析: n很小,知道用状压,但是比赛没做出来(脑子太死了,有一个限制条件在解题过程中每个学生的解题数的差不大于1,哎,关键在这句话,那就是说,在解题过程中必须先是每人解出一道题目,才能继续解题,那就是状态全部是1时处理成全部是0) dp[i][j]表示前i个题目解...

weixin_30535167的博客 103

hdu 5045 Contest(状压DP)

ContestTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2143    Accepted Submission(s): 878Problem DescriptionIn the ACM International Collegiate...

Timeclimber 273

HDU 5045 Contest(状压DP)

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...

weixin_30455067的博客 130
上一篇: HDU5025 状压+BFS
下一篇: HDU1045 水dfs....数据量太小了才16.....
NineFailure
博客等级 码龄11年 22粉丝 317原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值