Janken Master

시간 제한2초메모리 제한512 MB

요약
최대 14명의 참가자 각각의 가위바위보 확률이 주어질 때, 동점이면 레이팅이 가장 높은 사람이 이기는 토너먼트에서 우승 확률을 최대로 만드는 전략을 구한다.
난이도

보통10점 중 7점

유형
동적 계획법, 비트 연산, 확률, 게임 이론
정답자
아직 제출이 없습니다

문제

You are supposed to play the rock-paper-scissors game. There are NN players including you.

This game consists of multiple rounds. While the rounds go, the number of remaining players decreases. In each round, each remaining player will select an arbitrary shape independently. People who show rocks win if all of the other people show scissors. In this same manner, papers win rocks, scissors win papers. There is no draw situation due to the special rule of this game: if a round is tied based on the normal rock-paper-scissors game rule, the player who has the highest programming contest rating (this is nothing to do with the round!) will be the only winner of the round. Thus, some players win and the other players lose on each round. The losers drop out of the game and the winners proceed to a new round. They repeat it until only one player becomes the winner.

Each player is numbered from 11 to NN. Your number is 11. You know which shape the other N−1N-1 players tend to show, that is to say, you know the probabilities each player shows rock, paper and scissors. The ii-th player shows rock with r_ir\_i% probability, paper with p_ip\_i% probability, and scissors with s_is\_i% probability. The rating of programming contest of the player numbered ii is a_ia\_i. There are no two players whose ratings are the same. Your task is to calculate your probability to win the game when you take an optimal strategy based on each player's tendency and rating.

입력

The input consists of a single test case formatted as follows.

$N$ $a_1$ $a_2 \ r_2 \ p_2 \ s_2$ $\vdots$ $a_N \ r_N \ p_N \ s_N$

The first line consists of a single integer N (2≤N≤14)N \ (2 \le N \le 14). The second line consists of a single integer a_1 (1≤a_1≤N)a\_1 \ (1 \le a\_1 \le N). The (i+1)(i+1)-th line consists of four integers a_ia\_i, r_ir\_i, p_ip\_i and s_is\_i (1≤a_i≤N1 \le a\_i \le N, 0≤r_i,p_i,s_i≤1000 \le r\_i, p\_i, s\_i \le 100, r_i+p_i+s_i=100r\_i + p\_i + s\_i = 100) for i=2,…,Ni = 2, \ldots, N. It is guaranteed that a_1,…,a_Na\_1, \ldots, a\_N are pairwise distinct.

출력

Print the probability to win the game in one line. Your answer will be accepted if its absolute or relative error does not exceed 10−610^{-6}.

예제5

  1. 예제 1

    입력
    2
    2
    1 40 40 20
    
    예상 출력
    0.8
    
  2. 예제 2

    입력
    2
    1
    2 50 50 0
    
    예상 출력
    0.5
    
  3. 예제 3

    입력
    3
    2
    1 50 0 50
    3 0 0 100
    
    예상 출력
    1
    
  4. 예제 4

    입력
    3
    2
    3 40 40 20
    1 30 10 60
    
    예상 출력
    0.27
    
  5. 예제 5

    입력
    4
    4
    1 34 33 33
    2 33 34 33
    3 33 33 34
    
    예상 출력
    0.6591870816