CF678E.Another Sith Tournament

提高+/省选-

通过率:0%

时间限制:2.50s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

西斯锦标赛的规则众所周知:共有 nn 名西斯参加锦标赛。锦标赛首先随机选出两名尚未参战的西斯进行首场对决;其中一人战败身亡后,由一名尚未参战的西斯随机替补其位置。当然,每场西斯锦标赛的对决均以其中一方死亡告终。当仅剩一名西斯存活时,锦标赛结束。

绝地武士伊万意外地出现在西斯锦标赛的参赛者名单中。然而,他在原力光明面的强大实力使他能够影响每次选择——无论是初始对决双方的选定,还是每场对决后替补战败者位置的新人选——均可由他操控。显然,他绝不会错过这一优势机会。请帮助他计算自己最终获胜的概率。

输入格式

The first line contains a single integer n (1 ≤ n ≤ 18) — the number of participants of the Sith Tournament.

Each of the next n lines contains n real numbers, which form a matrix p__ij (0 ≤ p__ij ≤ 1). Each its element p__ij is the probability that the i-th participant defeats the j-th in a duel.

The elements on the main diagonal p__ii are equal to zero. For all different i, j the equality p__ij + p__ji = 1 holds. All probabilities are given with no more than six decimal places.

Jedi Ivan is the number 1 in the list of the participants.

第一行包含一个整数 nn(1≤n≤181 \leq n \leq 18)—— 表示西斯锦标赛的参赛者人数。

接下来的 nn 行,每行包含 nn 个实数,构成一个矩阵 pijp_{ij}(0≤pij≤10 \leq p_{ij} \leq 1)。其中每个元素 pijp_{ij} 表示第 ii 位参赛者在决斗中击败第 jj 位参赛者的概率。

主对角线上的元素 piip_{ii} 均为零。对于所有互不相同的 i,ji, j,满足等式 pij+pji=1p_{ij} + p_{ji} = 1。所有概率均以不超过六位小数的形式给出。

绝地武士伊万是参赛者列表中的第 1 号选手。

输出格式

Output a real number — the probability that Jedi Ivan will stay alive after the Tournament. Absolute or relative error of the answer must not exceed 10 - 6.

输出一个实数——绝地武士伊万在锦标赛后存活的概率。答案的绝对或相对误差不得超过 10−610^{-6}。

输入输出样例

  • 输入#1

    3
    0.0 0.5 0.8
    0.5 0.0 0.4
    0.2 0.6 0.0

    输出#1

    0.680000000000000

输入解题思路,AI测评打分。不知道怎么写?

首页