CF678E.Another Sith Tournament

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

The rules of Sith Tournament are well known to everyone. nn 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.

输入格式

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

Each of the next nn lines contains nn real numbers, which form a matrix pijp_{ij} ( 0<=pij<=10<=p_{ij}<=1 ). Each its element pijp_{ij} is the probability that the ii -th participant defeats the jj -th in a duel.

The elements on the main diagonal piip_{ii} are equal to zero. For all different ii , jj the equality pij+pji=1p_{ij}+p_{ji}=1 holds. All probabilities are given with no more than six decimal places.

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

输出格式

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 10610^{-6} .

输入输出样例

  • 输入#1

    3
    0.0 0.5 0.8
    0.5 0.0 0.4
    0.2 0.6 0.0
    

    输出#1

    0.680000000000000
    
首页