题目链接

http://acm.hdu.edu.cn/showproblem.php?pid=4800

Problem Description
A role-playing game (RPG and sometimes roleplaying game) is a game in which players assume the roles of characters in a fictional setting. Players take responsibility for acting out these roles within a narrative, either through literal acting or through a process of structured decision-making or character development.
Recently, Josephina is busy playing a RPG named TX3. In this game, M characters are available to by selected by players. In the whole game, Josephina is most interested in the "Challenge Game" part.
The Challenge Game is a team play game. A challenger team is made up of three players, and the three characters used by players in the team are required to be different. At the beginning of the Challenge Game, the players can choose any characters combination as the start team. Then, they will fight with N AI teams one after another. There is a special rule in the Challenge Game: once the challenger team beat an AI team, they have a chance to change the current characters combination with the AI team. Anyway, the challenger team can insist on using the current team and ignore the exchange opportunity. Note that the players can only change the characters combination to the latest defeated AI team. The challenger team gets victory only if they beat all the AI teams.
Josephina is good at statistics, and she writes a table to record the winning rate between all different character combinations. She wants to know the maximum winning probability if she always chooses best strategy in the game. Can you help her?
 
Input
There are multiple test cases. The first line of each test case is an integer M (3 ≤ M ≤ 10), which indicates the number of characters. The following is a matrix T whose size is R × R. R equals to C(M, 3). T(i, j) indicates the winning rate of team i when it is faced with team j. We guarantee that T(i, j) + T(j, i) = 1.0. All winning rates will retain two decimal places. An integer N (1 ≤ N ≤ 10000) is given next, which indicates the number of AI teams. The following line contains N integers which are the IDs (0-based) of the AI teams. The IDs can be duplicated.
 
Output
For each test case, please output the maximum winning probability if Josephina uses the best strategy in the game. For each answer, an absolute error not more than 1e-6 is acceptable.
 
Sample Input
4
0.50 0.50 0.20 0.30
0.50 0.50 0.90 0.40
0.80 0.10 0.50 0.60
0.70 0.60 0.40 0.50
3
0 1 2
 
Sample Output
0.378000
 
Source
 
 
Recommend
We have carefully selected several similar problems for you:  5901 5899 5898 5897 5896 
 
 
题意:输入M,表示有K=C(M,3) 种机器人,然后输入k*k的矩阵 s[i][j]表示第i种机器人打赢第j种机器人的概率,接下来输入N和N个数,每个数表示N个机器人的种类,现在你可以任选一种机器人依次和这N个机器人打,每次打赢一个机器人后,你可以和他交换机器人,求打败N个机器人的最大概率;
 
思路:定义dp[i] 表示交换或没交换 当前你的机器人为i 时打败前x个机器人的最大概率;
 
代码如下:
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cstring>
using namespace std;
typedef long long LL;
double s[][];
double d1[];
int a[]; int main()
{
int M,N;
while(scanf("%d",&M)!=EOF)
{
M=M*(M-)*(M-)/;
for(int i=;i<M;i++)
{
for(int j=;j<M;j++)
scanf("%lf",&s[i][j]);
}
scanf("%d",&N);
for(int i=;i<N;i++)
scanf("%d",&a[i]);
for(int i=;i<M;i++)
d1[i]=1.0;
for(int i=;i<N;i++)
{
int x=a[i];
double r=0.0;
for(int j=;j<M;j++)
{
d1[j]=d1[j]*s[j][x];
r=max(r,d1[j]);
}
d1[x]=max(d1[x],r);
}
printf("%.6lf\n",d1[a[N-]]);
}
return ;
}

2013 Asia Changsha Regional Contest---Josephina and RPG(DP)的更多相关文章

  1. The 2013 ACM-ICPC Asia Changsha Regional Contest - J

    Josephina and RPG Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge A role-playin ...

  2. The 2013 ACM-ICPC Asia Changsha Regional Contest - K

    Pocket Cube Time Limit: 2 Seconds      Memory Limit: 65536 KB Pocket Cube is a 3-D combination puzzl ...

  3. The 2013 ACM-ICPC Asia Changsha Regional Contest - A

    Alice's Print Service Time Limit: 2 Seconds      Memory Limit: 65536 KB Alice is providing print ser ...

  4. 2013 Asia Chengdu Regional Contest

    hdu 4786 Fibonacci Tree http://acm.hdu.edu.cn/showproblem.php?pid=4786 copyright@ts 算法源于ts,用最小生成树可以求 ...

  5. 2013 Asia Hangzhou Regional Contest

    Lights Against Dudely http://acm.hdu.edu.cn/showproblem.php?pid=4770 15个位置,所以可以暴力枚举那些放,对于放的再暴力枚举哪个转, ...

  6. HDU4771(2013 Asia Hangzhou Regional Contest )

    http://acm.hdu.edu.cn/showproblem.php?pid=4771 题目大意: 给你一幅图(N*M)“@”是起点,"#"是墙,“.”是路,然后图上有K个珠 ...

  7. 2013 Asia Hangzhou Regional Contest hdu4780 Candy Factory

    参考:https://blog.csdn.net/sd_invol/article/details/15813671 要点 每个任务的结束时间是固定的,不受任何因素影响 机器只在最一开始有用,在那之后 ...

  8. zoj 3659 Conquer a New Region The 2012 ACM-ICPC Asia Changchun Regional Contest

    Conquer a New Region Time Limit: 5 Seconds      Memory Limit: 32768 KB The wheel of the history roll ...

  9. 2018 ACM-ICPC Asia Beijing Regional Contest (部分题解)

    摘要 本文主要给出了2018 ACM-ICPC Asia Beijing Regional Contest的部分题解,意即熟悉区域赛题型,保持比赛感觉. Jin Yong’s Wukong Ranki ...

随机推荐

  1. Java多线程

    一:进程与线程 概述:几乎任何的操作系统都支持运行多个任务,通常一个任务就是一个程序,而一个程序就是一个进程.当一个进程运行时,内部可能包括多个顺序执行流,每个顺序执行流就是一个线程.   进程:进程 ...

  2. 使用 Nodejs 搭建简单的Web服务器

    使用Nodejs搭建Web服务器是学习Node.js比较全面的入门教程,因为要完成一个简单的Web服务器,你需要学习Nodejs中几个比较重要的模块,比如:http协议模块.文件系统.url解析模块. ...

  3. 在ASP.NET Core中使用百度在线编辑器UEditor

    在ASP.NET Core中使用百度在线编辑器UEditor 0x00 起因 最近需要一个在线编辑器,之前听人说过百度的UEditor不错,去官网下了一个.不过服务端只有ASP.NET版的,如果是为了 ...

  4. console的高级使用

    1.console.table()用来表格化展示数据. var people = { zqz: { name: 'zhaoqize', age: 'guess?' }, wdx: { name: 'w ...

  5. JavaScript动画-拖拽改变元素大小

    ▓▓▓▓▓▓ 大致介绍 拖拽改变元素大小是在模拟拖拽上增加了一些功能 效果:拖拽改变元素大小 ▓▓▓▓▓▓ 拖拽改变元素大小原理 首先这个方块得知道我们想要改变这个它的大小,所以我给它设定一个范围,当 ...

  6. H5坦克大战之【玩家控制坦克移动】

    自从威少砍下45+11+11的大号三双之后,网上出现了各种各样的神级段子,有一条是这样的: 威少:Hey,哥们,最近过得咋样! 浓眉:对方开启了好友验证,请先添加对方为好友 威少:...... JRS ...

  7. 原生javascript 固定表头原理与源码

    我在工作中需要固定表头这个功能,我不想去找,没意思.于是就写了一个,我写的是angularjs 自定义指令 起了个 "fix-header" ,有人叫  "freeze- ...

  8. 玩转spring boot——结合redis

    一.准备工作 下载redis的windows版zip包:https://github.com/MSOpenTech/redis/releases 运行redis-server.exe程序 出现黑色窗口 ...

  9. CSS 3学习——box-sizing和背景

    box-sizing 在CSS 2中设置元素的width和height仅仅是设置了元素内容区的宽和高,元素实际的尺寸是margin + border + padding + 内容区. CSS 3(截止 ...

  10. VS2015在创建项目时的一些注意事项

    一.下面是在创建一个新的项目是我最常用的,现在对他们一一做一个详细的介绍: 1.Win32控制台应用程序我平时编写小的C/C++程序都用它,它应该是用的最多的. 2.名称和解决方案名称的区别:名称是项 ...