Under construction

Still being built. Things may change

Soccer

Interview

Time limit2sMemory limit128 MB

Summary
Compute probability distribution of final scores after up to T seconds of a stochastic soccer simulation with passing, stealing, shooting, and absorbing states.
Level

Medium5 of 10

Topics
Probability, Dynamic programming, Simulation, Combinatorics
Solved
No attempts yet

Problem

2N2N players are split into two teams playing soccer. Every player wears their own team's uniform, and the shirt numbers run from 11 to NN on each team.

Each player knows their own shooting accuracy pp, the set FF of teammates they can pass to, and the set EE of opposing players who can steal the ball from them.

Once a player gets the ball, exactly one of the following three events happens during the next 11 second:

  1. Pass to one of the teammates in FF.
  2. Have the ball stolen by one of the opposing players in EE.
  3. Take a shot at the goal.

When a player shoots, they score with probability equal to their accuracy pp. After the shot, regardless of the outcome, player number 11 of the opposing team receives the ball.

The three events occur with probability ratio ∣F∣:∣E∣:1|F| : |E| : 1, and previous events do not affect later ones. (Here ∣S∣|S| denotes the size of set SS.) For a pass or a steal, every player in the relevant set is equally likely to be chosen. The time during which no player holds the ball is negligibly short.

The match starts with player 11 of the first team holding the ball. The match ends as soon as some team scores RR goals, or once TT seconds have elapsed since the start. For every possible final score, compute the probability that the match ends with that score.

The figure below illustrates one example input.

Input

The first line contains NN, RR, and TT. (1≤N≤1001 \le N \le 100, 1≤R≤101 \le R \le 10, 1≤T≤5001 \le T \le 500)

The next NN lines describe the players of the first team in order from number 11, followed by NN lines describing the players of the second team in order from number 11.

Each player's description begins with that player's accuracy pp (0≤p≤10 \le p \le 1), followed by the size nFn_F of set FF and the size nEn_E of set EE (0≤nF≤N−10 \le n_F \le N-1, 0≤nE≤N0 \le n_E \le N). Then come nF+nEn_F + n_E integers separated by spaces: the first nFn_F are the shirt numbers of the teammates in FF, and the remaining nEn_E are the shirt numbers of the opposing players in EE. A player's own number is never contained in FF.

Output

There are exactly R×(R+2)R \times (R+2) theoretically possible final scores. For each of them, print the probability that the match ends with that score as an irreducible fraction in the form numerator/denominator, one per line. Print 0/1 when the probability is 00 and 1/1 when it is 11.

Print the scores ordered by the first team's score ascending, breaking ties by the second team's score ascending.

Examples2

  1. Example 1

    Input
    1 1 2
    0.5 0 1 1
    0.5 0 1 1
    
    Expected output
    9/16
    3/16
    1/4
    
  2. Example 2

    Input
    2 2 5
    0.0 1 2 2 1 2
    1.0 0 0
    0.5 1 0 2
    0.5 1 0 1
    
    Expected output
    33/128
    9/32
    9/128
    11/64
    21/128
    3/128
    1/64
    1/64