hdu 5045(上海网赛1004)Contest
来源:互联网 发布:人工智能产业链分层图 编辑:程序博客网 时间:2024/05/10 02:14
题意:一个比赛,n个人搞,有m道题,只能按顺序交题,每题只能一个人去A,给出每个人A每道题的概率。但是为了公平,在任何时刻不能有人比另一个人多做1道题以上。
思路:状压DP。10个人,用10位二进制数表示。如果当前某人多做了题,那一位就是1,否则是0,不允许多做两题及以上的状态出现,还有如果是“全1”的状态,直接置为“全0”。
#include <iostream> #include <stdio.h> #include <cmath> #include <algorithm> #include <iomanip> #include <cstdlib> #include <string> #include <vector> #include <queue> #include <stack> #include <map> #include <set> #include <string.h>#include <ctype.h> using namespace std; #define ll long longdouble dp[1025][1010];double a[12][1025];int main(){ int t; cin>>t; int cas=0; while(t--){ cas++; int n,m; cin>>n>>m; //init for(int i=0;i<=1024;i++){ for(int j=0;j<=m;j++){ dp[i][j]=-1.0; } } dp[0][0]=0.0; // for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ scanf("%lf",&a[i][j]); } } int full=(1<<n)-1; double ans=0.0; for(int j=1;j<=m;j++){ for(int i=0;i<full;i++){ for(int k=1;k<=n;k++){ int cur=1<<(k-1); if(dp[i][j-1]<0)continue; //cout<<cur<<"...."<<i<<endl; if(cur&i)continue; int newi=i|cur; if(newi==full)newi=0; dp[newi][j]=max(dp[newi][j],dp[i][j-1]+a[k][j]); if(j==m)ans=max(ans,dp[newi][j]); } } } printf("Case #%d: %.5lf\n",cas,ans); } return 0;}
0 0
- hdu 5045(上海网赛1004)Contest
- HDU 5045 Contest (2014上海网络赛)
- HDU 5045 Contest(概率dp,状态压缩,2014上海网络赛1004)
- hdu 5045 Contest--2014acm上海赛区网络赛
- Hdu 5045 Contest (2014 上海Online) (状态压缩dp)
- 2014上海网络赛Contest
- 2014上海网络赛1004||hdu5045 contest【状态压缩dp】
- HDU 5045 Contest(DFS 回溯)
- hdu - 5045 - Contest(状态压缩dp)
- HDU 5045 Contest(状压DP)
- HDU-5045 Contest(状压DP)
- hdu 5045 Contest(dp)
- HDU 5045 Contest
- hdu 5045 Contest
- hdu 5045 F - Contest
- 20140930 【 DP - 状态压缩 】 2014-上海区域赛-网络预选赛 hdoj 5045 Contest
- HDU 5045 5047 5050 5053(上海网络赛E,F,I,L)
- hdu 5053(2014上海网赛1012) the Sum of Cube
- 【iOS开发-18】UIWindow和UIView是什么关系,随着xcode版本增进UIWindow不重要了吗?求解答
- C++的iostream标准库介绍和使用详解
- Android五种数据存储方式
- android 数据处理之 SharedPreferences
- Android签到功能的实现
- hdu 5045(上海网赛1004)Contest
- android中4种布局详解
- 软工视频——软件计划
- HDU 5046 Airport DLX 2014 ACM/ICPC Asia Regional Shanghai Online
- 经典算法研究系列:五、红黑树算法的实现与剖析
- iOS UIButton 设置图片不变型 setImage:
- C++_链表
- 在Ubuntu 12.4下安装qtcreator的绘图控件qwt,简单轻松
- introduction to algorithms data structure lesson_1 stack