[CF678E] Another Sith Tournament([JZOJ4648] 锦标赛)
来源:互联网 发布:mac 多屏幕切换快捷键 编辑:程序博客网 时间:2024/05/19 13:26
Description
The rules of Sith Tournament are well known to everyone. n Sith take part in the Tournament. The Tournament starts with the random choice of two Sith who will fight in the first battle. As one of them loses, his place is taken by the next randomly chosen Sith who didn’t fight before. Does it need to be said that each battle in the Sith Tournament ends with a death of one of opponents? The Tournament ends when the only Sith remains alive.
Jedi Ivan accidentally appeared in the list of the participants in the Sith Tournament. However, his skills in the Light Side of the Force are so strong so he can influence the choice of participants either who start the Tournament or who take the loser’s place after each battle. Of course, he won’t miss his chance to take advantage of it. Help him to calculate the probability of his victory.
下面是译文
403机房最近决定举行一场锦标赛。锦标赛共有N个人参加,共进行N-1轮。第一轮随机挑选两名选手进行决斗,胜者进入下一轮的比赛,第二轮到第N-1轮再每轮随机挑选1名选手与上一轮胜利的选手决斗,最后只剩一轮选手。第i名选手与第j名选手决斗,第i名选手胜利的概率是a[i][j].
作为一号选手的富榄(%%%)想知道如何安排每轮出场的选手可以使得他获胜的概率最大,并求出这个最大概率。
对于30%的数据,N<=10
对于60%的数据,N<=15
对于100%的数据,N<=18
Solution
额~~~这谁翻译的。。。。。
状压性质显然。
然而顺着状压
我们考虑倒着状压
设
枚举
那么我们倒着转移,显然可以从
那么就显然
(这里
Code
#include<cstdio>#include<cstdlib>#include<cmath>#include<cstring>#include<algorithm>#include<iostream>#define fo(i,a,b) for(i=a;i<=b;i++)#define fod(i,a,b) for(i=a;i>=b;i--)using namespace std;int n,cf[19],sx[300001],bz[300001],num;double f[19][300001],a[19][19]; int main(){ freopen("match.in","r",stdin); cin>>n; int i,j,k,p; cf[0]=1; fo(i,0,n-1) { if (i!=0)cf[i]=cf[i-1]*2; fo(j,0,n-1) scanf("%lf",&a[i][j]); } cf[n]=cf[n-1]*2; f[0][1]=1; sx[0]=0; bz[0]=0; fo(i,0,num) { fo(j,0,n-1) { if ((sx[i]&cf[j])==0&&bz[sx[i]+cf[j]]==0) { bz[sx[i]+cf[j]]=bz[sx[i]]+1; sx[++num]=sx[i]+cf[j]; } } } fo(i,2,n) { fo(p,2,cf[n]-1) { if (bz[p]==i) fo(j,0,n-1) { if ((cf[j]&p)>0) { fo(k,0,n-1) { if((cf[k]&p)>0&&j!=k) { f[j][p]=max(f[j][p],f[j][p-cf[k]]*a[j][k]+f[k][p-cf[j]]*a[k][j]); } } } } } } double ans; fo(i,0,n-1) ans=max(ans,f[i][cf[n]-1]); printf("%.7lf",ans);}
- [CF678E] Another Sith Tournament([JZOJ4648] 锦标赛)
- cf678E. Another Sith Tournament
- CF678E Another Sith Tournament(概率dp+状压dp)
- 【Codeforces 678E】Another Sith Tournament &【JZOJ 4648】锦标赛
- Another Sith Tournament
- 【JZOJ4648】锦标赛
- Codeforces 678E(Another Sith Tournament)
- cf 678E Another Sith Tournament
- Educational Codeforces Round 13 E. Another Sith Tournament
- 【Codeforces 696B】Another Sith Tournament &【JZOJ 4647】寻找
- Codeforces 678E Another Sith Tournament(状压dp)
- Codeforces 678E Another Sith Tournament(状压dp,概率dp)
- Educational Codeforces Round 13 E. Another Sith Tournament 状压dp
- Educational Codeforces Round 13 E. Another Sith Tournament 状态压缩dp
- 锦标赛
- 锦标赛排序树到底是满二叉树还是完全二叉树(Tournament Tree is FBT or CBT?)
- GYM 101149 F.The Weakest Sith(水~)
- 锦标赛排序(胜者树,记录胜者)
- 8086汇编语言 e命令不见旧内容 只写入新内容
- UVA 202 有理数化为循环小数求循环节 UVA 11809 对数处理数据
- 基于python的双色球程序
- 彻底理解ThreadLocal
- Kafka剖析:Kafka背景及架构介绍
- [CF678E] Another Sith Tournament([JZOJ4648] 锦标赛)
- 监听菜单列表点击事件
- Android设计模式之桥接模式
- 图片上传到服务器(工具类)
- 死锁
- 流转换成字符串
- Kafka设计解析:Kafka Consumer解析
- 开始的安卓
- Css3 Media Query实现响应式的方法总结