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. Win32 API翻译

    这是从MSDN里面的Win32 SDK API函数.结构.通知.消息等等超过3000个.其中一半是整理自别人翻译. http://files.cnblogs.com/files/sishenzaixi ...

  2. Postman安装与使用

    Postman一款非常流行的API调试工具.其实,开发人员用的更多.因为测试人员做接口测试会有更多选择,例如Jmeter.soapUI等.不过,对于开发过程中去调试接口,Postman确实足够的简单方 ...

  3. Spring注解定时器使用

    一.首先要配置我们的spring-service.xml 1.xmlns 多加下面的内容 xmlns:task="http://www.springframework.org/schema/ ...

  4. laravel学习笔记二

    代码编写提示工具

  5. 在windows下远程访问linux桌面

    一.安装xrdp工具: #  yum install xrdp #   yum install tigervnc-server #   service xrdp start 以上三个命令执行完毕安装完 ...

  6. Parallel 类并行任务(仅仅当执行耗时操作时,才有必要使用)

    using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using S ...

  7. 如何在已有的 Web 应用中使用 ReactJS

    原文:How to Sprinkle ReactJS into an Existing Web Application 译者:nzbin 当我们学习一项新技术,可能是一个 JavaScript 框架, ...

  8. HTML60秒倒计时

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. MacOS搭建本地服务器

    MacOS搭建本地服务器 一,需求分析 1.1,开发app(ios android)时通常需往app中切入web页面,直接导入不行,故需搭建本地的测试网站服务,通过IP嵌入访问页面. 1.2,开发小程 ...

  10. Python进阶1---高阶函数、柯里化

    高阶函数 不相等  自定义sort函数 内建函数--高阶函数 #sort函数 def sort2(lst,key = None,reverse = False): res = [] if key is ...