CF678E Another Sith Tournament(概率dp+状压dp)
来源:互联网 发布:淘宝vip专享活动 编辑:程序博客网 时间:2024/05/20 04:11
这题又想了会???一开始题都没读对orz。。其实就是让你安排一个比赛顺序,要求1最后存活的概率最大,求这个最大的概率。dp[s][i]表示状态s时擂主为i+1,最后1活下来的最大概率 。我们考虑倒着推(因为正着推难以统计答案x),则状态转移很显然:见代码。。。初始值给dp[1][0]=1,因为要求最后1存活下来。复杂度O(2^n*n^2)
#include <bits/stdc++.h>using namespace std;#define inf 0x3f3f3f3f#define ll long long#define N 20int n,bin[N];double a[N][N],dp[300000][N],ans=0;//dp[s][i]表示状态s时擂主为i+1,最后1活下来的最大概率 int main(){// freopen("a.in","r",stdin); scanf("%d",&n);bin[0]=1; for(int i=1;i<=n;++i) bin[i]=bin[i-1]<<1; for(int i=0;i<n;++i) for(int j=0;j<n;++j) scanf("%lf",&a[i][j]); memset(dp,0,sizeof(dp));dp[1][0]=1; for(int s=2;s<=bin[n]-1;++s) for(int i=0;i<n;++i){ if(!(s&bin[i])) continue; for(int j=0;j<n;++j){ if(!(s&bin[j])) continue; dp[s][i]=max(dp[s][i],a[i][j]*dp[s-bin[j]][i]+a[j][i]*dp[s-bin[i]][j]); } } for(int i=0;i<n;++i) ans=max(ans,dp[bin[n]-1][i]); printf("%.7f\n",ans); return 0;}
阅读全文
0 0
- CF678E Another Sith Tournament(概率dp+状压dp)
- Codeforces 678E Another Sith Tournament(状压dp,概率dp)
- cf678E. Another Sith Tournament
- [CF678E] Another Sith Tournament([JZOJ4648] 锦标赛)
- Codeforces 678E Another Sith Tournament(状压dp)
- Educational Codeforces Round 13 E. Another Sith Tournament 状压dp
- Another Sith Tournament
- Educational Codeforces Round 13 E. Another Sith Tournament 状态压缩dp
- Codeforces 678E(Another Sith Tournament)
- cf 678E Another Sith Tournament
- Just another Robbery(概率dp)
- Educational Codeforces Round 13 E. Another Sith Tournament
- 【Codeforces 696B】Another Sith Tournament &【JZOJ 4647】寻找
- 【Codeforces 678E】Another Sith Tournament &【JZOJ 4648】锦标赛
- 【LightOJ 1079】Just another Robbery(概率DP+背包)
- LightOJ-1079-Just another Robbery (概率dp)
- LightOJ 1079 Just another Robbery 概率dp
- bzoj1076【概率dp+状压】
- 文章标题
- jupyter notebook的安装与使用
- BZOJ 2618: [Cqoi2006]凸多边形(半平面交)
- ubuntu更新阿里源与桌面快捷操作
- 机器学习第4章第1节 : R语言基本语法及操作
- CF678E Another Sith Tournament(概率dp+状压dp)
- js之substr与substring的区别
- androidStudio使用总结(一)
- 01-天亮大数据系统教程之初识Hadoop
- [设计]责任链模式
- get_image_pointer1
- python核心编程读书笔记--第2章 入门
- js任意进制转换--parseInt与toString
- js随机生成hash值