https://nanti.jisuanke.com/t/31455

题意

给一个3*3的方格填入 1-9 九个数 
有些数是已知的,有些数是对方已知但我未知的,有些数是大家都未知的 
我要计算取得最大的对应值的期望

分析

题意有点难懂。

首先先枚举把剩下的数填入星号的情况(其实就是枚举星号的排列),这是对方所能知道的所有信息,然后对方将取八种决策中最优的情况,而因为井号的存在,所以其排列也会影响每种决策的分数,所以接着要枚举井号的排列情况,对于每种情况累加每个决策的分数,最后枚举完后,要除以井号排列数(期望=分数*概率),然后对方便会选择期望最高的决策,累加到最后答案中,枚举完所有星号的之后,需要将最后答案除以星号排列数

#include<bits/stdc++.h>
using namespace std;
double ans;
int cnt,tot;
bool vis[];
char s[][];
int p[],a[],tmp[];
int state[];
int S[][]={
,,,
,,,
,,,
,,,
,,,
,,,
,,,
,,
};
int score[]={,,,,,,,,,,,,,,
,,,,,,,,,,};
int fac[];
void work(){
vector<int> num;
for(int i=;i<;i++) state[i]=;
for(int i=;i<=;i++){
if(!vis[i]){
num.push_back(i);
}
} do{
int na=,nb=;
for(int i=;i<;i++){
for(int j=;j<;j++){
if(s[i][j]=='*') tmp[i*+j]=p[na++];
else if(s[i][j]=='#') tmp[i*+j]=num[nb++];
else tmp[i*+j]=s[i][j]-'';
}
}
for(int i=;i<;i++){
int sum=;
for(int j=;j<;j++){
sum+=tmp[S[i][j]];
}
state[i]+=score[sum];
}
}while(next_permutation(num.begin(),num.end()));
double res=;
for(int i=;i<;i++){
res=max(res,state[i]*1.0/fac[num.size()]);
}
ans+=res;
}
void dfs(int pos){
if(pos==tot){
cnt++;
work();
return;
}
for(int i=;i<=;i++){
if(!vis[i]){
vis[i]=true;
p[pos]=i;
dfs(pos+);
vis[i]=false;
}
}
} int main(){
fac[]=;
for(int i=;i<;i++) fac[i]=fac[i-]*i;
int T;
scanf("%d",&T);
while(T--){
memset(vis,false,sizeof(vis));
tot=;
for(int i=;i<;i++){
scanf("%s",s[i]);
int len = strlen(s[i]);
for(int j=;j<len;j++)
if(s[i][j]=='*') tot++;
else if(isdigit(s[i][j])) vis[s[i][j]-'']=true;
}
ans=cnt=;
dfs();
ans=ans/cnt;
printf("%.8f\n",ans);
}
return ;
}

ACM-ICPC 2018 徐州赛区网络预赛 C Cacti Lottery(期望+暴力)的更多相关文章

  1. ACM-ICPC 2018 徐州赛区网络预赛 C Cacti Lottery(暴力+期望)

    链接https://nanti.jisuanke.com/t/31455 思路 首先先枚举把剩下的数填入星号的情况(其实就是枚举星号的排列),这是对方所能知道的所有信息,然后对方将取八种决策中最优的情 ...

  2. ACM-ICPC 2018 徐州赛区网络预赛 G. Trace (思维,贪心)

    ACM-ICPC 2018 徐州赛区网络预赛 G. Trace (思维,贪心) Trace 问答问题反馈 只看题面 35.78% 1000ms 262144K There's a beach in t ...

  3. ACM-ICPC 2018 徐州赛区网络预赛 J. Maze Designer (最大生成树+LCA求节点距离)

    ACM-ICPC 2018 徐州赛区网络预赛 J. Maze Designer J. Maze Designer After the long vacation, the maze designer ...

  4. 计蒜客 1460.Ryuji doesn't want to study-树状数组 or 线段树 (ACM-ICPC 2018 徐州赛区网络预赛 H)

    H.Ryuji doesn't want to study 27.34% 1000ms 262144K   Ryuji is not a good student, and he doesn't wa ...

  5. ACM-ICPC 2018 徐州赛区网络预赛 B(dp || 博弈(未完成)

    传送门 题面: In a world where ordinary people cannot reach, a boy named "Koutarou" and a girl n ...

  6. ACM-ICPC 2018 徐州赛区网络预赛 B. BE, GE or NE

    In a world where ordinary people cannot reach, a boy named "Koutarou" and a girl named &qu ...

  7. ACM-ICPC 2018 徐州赛区网络预赛 H. Ryuji doesn't want to study

    262144K   Ryuji is not a good student, and he doesn't want to study. But there are n books he should ...

  8. ACM-ICPC 2018 徐州赛区网络预赛 F. Features Track

    262144K   Morgana is learning computer vision, and he likes cats, too. One day he wants to find the ...

  9. ACM-ICPC 2018 徐州赛区网络预赛 I. Characters with Hash

    Mur loves hash algorithm, and he sometimes encrypt another one's name, and call him with that encryp ...

随机推荐

  1. Docker: 快速搭建LNMP网站平台

    快速搭建LNMP网站平台 步骤: 1.自定义网络(这里建立一个自定义网络,名字叫 lnmp, 让LNMP网站的服务,都加入这个自定义网络)docker network create lnmp2.创建M ...

  2. python基础篇实战

    1. 判断下面的结果 # 1. 判断下面的结果 # 1 > 1 or 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6 pri ...

  3. .NET CORE学习笔记系列(2)——依赖注入【2】基于IoC的设计模式

    原文:https://www.cnblogs.com/artech/p/net-core-di-02.html 正如我们在<控制反转>提到过的,很多人将IoC理解为一种“面向对象的设计模式 ...

  4. Configuring Apache Kafka Security

    This topic describes additional steps you can take to ensure the safety and integrity of your data s ...

  5. java多线程(死锁,lock接口,等待唤醒机制)

    一.Lock接口 常用方法 Lock提供了一个更加面对对象的锁,在该锁中提供了更多的操作锁的功能. 使用Lock接口,以及其中的lock()方法和unlock()方法替代同步,对电影院卖票案例中Tic ...

  6. docker其他参考资料

    https://yeasy.gitbooks.io/docker_practice/image/build.html https://blog.csdn.net/weixin_42596342/art ...

  7. Linux 内核空间与用户空间

    本文以 32 位系统为例介绍内核空间(kernel space)和用户空间(user space). 内核空间和用户空间 对 32 位操作系统而言,它的寻址空间(虚拟地址空间,或叫线性地址空间)为 4 ...

  8. Redis原理

    RESP协议 支持tcp协议.基本数据类型,比如数组,字符串等,也可支持其他的通信场景. 模拟redis接收传输过来的set数据 //ServerSocket监听6379端口模拟redis publi ...

  9. Linux soft lockup分析

    关键词:watchdog.soft lockup.percpu thread.lockdep等. 近日遇到一个soft lockup问题,打印类似“[ 56.032356] NMI watchdog: ...

  10. vue-使用keep-alive优化网页性能

    export default{ name: 'Home', data () { return { iconList: [], recommendList: [], swiperList: [], we ...