cf 678E Another Sith Tournament
来源:互联网 发布:mysql 主键索引作用 编辑:程序博客网 时间:2024/05/29 15:10
状压DP,注意顺序和转移。(另:若用dp[i][S]表示i获胜的概率,是否可做?感觉其实和直接表示1的胜率差不太多,只是后者不太好想到)
//QWsin#include<cmath>#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespace std;const int maxn=20;const int maxm=(1<<18)+10;double p[maxn][maxn];double dp[maxn][maxm];//dp[i][S]表示i胜,S集合还没比,1的胜率 int main(){ int n;cin>>n; dp[1][0]=1; for(int i=1;i<=n;++i) for(int j=1;j<=n;++j) scanf("%lf",p[i]+j); int ALL=(1<<n) - 1; for(int S=1;S<ALL;++S) { for(int i=1;i<=n;++i) if(!(S & (1<<(i-1)))) //枚举胜者 { for(int j=1;j<=n;++j) if(S & (1<<(j-1))) { dp[i][S]=max(dp[i][S],dp[j][S ^ 1<<(j-1)]*p[j][i]+dp[i][S^1<<(j-1)]*p[i][j]); } } } double ans=0; for(int i=1;i<=n;++i)ans=max(ans,dp[i][ALL ^ (1<<(i-1))]); cout<<ans; return 0;}
0 0
- cf 678E Another Sith Tournament
- Codeforces 678E(Another Sith Tournament)
- 【Codeforces 678E】Another Sith Tournament &【JZOJ 4648】锦标赛
- Codeforces 678E Another Sith Tournament(状压dp)
- Codeforces 678E Another Sith Tournament(状压dp,概率dp)
- cf678E. Another Sith Tournament
- Another Sith Tournament
- Educational Codeforces Round 13 E. Another Sith Tournament
- Educational Codeforces Round 13 E. Another Sith Tournament 状压dp
- Educational Codeforces Round 13 E. Another Sith Tournament 状态压缩dp
- [CF678E] Another Sith Tournament([JZOJ4648] 锦标赛)
- 【Codeforces 696B】Another Sith Tournament &【JZOJ 4647】寻找
- CF678E Another Sith Tournament(概率dp+状压dp)
- CF 283E Cow Tennis Tournament(线段树)
- CF #439 E Another Maximum Problem
- ACM->CF Knight Tournament
- cf 678 E
- cf 678E
- 正交设计助手的使用教程(设计测试用例的工具)
- 探讨:小球沿不同路线运动时的水平速度
- 2.13.1
- hdu 1172猜数字
- 数据结构实验之栈一:进制转换
- cf 678E Another Sith Tournament
- Spring AOP 实现原理
- POJ-2777-Count Color
- ucos系统任务切换过程
- POJ3321 Apple Tree
- PICT使用教程(设计测试用例工具)
- hdoj1002
- 基础知识(二)
- 操作系统实战之从裸机到内核(x86-64)