Bingo for the Win!

시간 제한1초메모리 제한1024 MB

요약
숫자가 중복될 수 있는 시트를 가진 n명의 선수가 반응 속도 순서대로 있을 때, 무작위 호출 순서에서 각 선수가 가장 늦게 모든 숫자를 지울 확률을 구한다.
난이도

어려움10점 중 9점

유형
확률, 조합론, 수학
정답자
아직 제출이 없습니다

문제

Bingo is a game of chance for multiple players. Each player receives a sheet with some numbers, and a game master then calls out these numbers in a random order. Players cross off the numbers that they have heard, and the first player to cross off all their numbers wins the game. This basic version of the game has a reputation for being, well, a bit sedate. No particular action is required of the players except for not falling asleep.

In this problem we will analyze a more dynamic version of Bingo that requires quick thinking. In our version, called Speed Bingo, the game master also calls out the numbers from the sheets in a random order. However, whenever a number is called out, only the first player to signal that he or she has the number is allowed to cross it off their sheet. If a player has the same number multiple times, only one copy may be crossed off at a time. When multiple players have the same number(s) on their sheets, whoever has the fastest reaction time has an advantage in winning Speed Bingo. But how big an advantage? That’s what we need your help to find out.

Formally, there are nn players, each receiving a (possibly) different sheet of kk (not necessarily distinct) numbers. Player 11 is faster to react than player 22, who in turn is faster than player 33, and so on, with player nn being the slowest. Consider the following example, corresponding to the first sample input, where three players receive four numbers each:

When number “1” is called for the first time, player 11—being faster—will get to cross it off their sheet. The second time “1” is called, player 22 will get to cross it off. So on average, we would expect player 11 to do better than players 22 and 33, since both of them will need some numbers that player 11 will get to first. However, since players 22 and 33 have no numbers in common, their performances will be independent of each other, even though player 22 is faster than player 33.

Suppose the game is played until all players have crossed off all of their numbers, that is, until all n⋅kn \cdot k numbers on all of the sheets (including appropriate repetitions) have been read. Assuming the order of the numbers is uniformly random, how likely is it for each player to finish last?

입력

The input describes a single game of Speed Bingo. The first line contains two integers nn and kk, the number of players and number of numbers on each sheet (1≤n≤1001 ≤ n ≤ 100, 1≤k≤1,0001 ≤ k ≤ 1\\, 000). This is followed by nn lines containing kk integers each, where the iith line gives the numbers on the sheet for the iith player. All those numbers are between 11 and 10910^9, inclusive.

출력

Output nn lines, one for each player. The iith line should contain the probability that player ii finishes last. All values must be accurate to an absolute error of at most 10−610^{-6}.

예제2

  1. 예제 1

    입력
    3 4
    1 2 3 4
    1 2 5 6
    3 4 7 8
    
    예상 출력
    0.000000000
    0.500000000
    0.500000000
    
  2. 예제 2

    입력
    4 2
    1 2
    3 4
    10 5
    7 8
    
    예상 출력
    0.250000000
    0.250000000
    0.250000000
    0.250000000