Under construction

Still being built. Things may change

Leaderboard Effect

Time limit3sMemory limit1024 MB

Summary
Compute the limiting proportion of teams that solve each problem when teams choose unread problems according to leaderboard solution counts.
Level

Hard9 of 10

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

Problem

You are in charge of a programming contest with several distinct problems and an overall time limit. The judges provide a reading time, a coding time, and a solution probability for each problem.

During the contest, teams can view a leaderboard that shows the accepted submissions of each team. Seeing the leaderboard can affect teams' strategies. All teams follow this strategy when solving problems in the contest:

  1. Choose a problem to read. First, they gather all problems they have not yet read. If they have read all problems, they spend the rest of the contest doing nothing. If none of these problems has any solutions, they choose one uniformly at random. Otherwise, they choose a problem to read with probability proportional to its number of solutions. For example, if problems A, B, and C have 33, 11, and 00 solutions, respectively, they choose A with probability 34\frac{3}{4}, B with probability 14\frac{1}{4}, and C with probability 04\frac{0}{4}.
  2. After choosing a problem, they first read it. This always takes that problem's reading time. After they finish reading, they know whether they can solve it. They can solve it with the given probability, and deciding whether they can takes no time. If they cannot solve it, they go back to step 1 and choose another problem to read. If they can solve it, they spend that problem's coding time, even if not enough contest time remains to finish, and then go back to step 1 to choose another problem to read. Once a team finishes coding the chosen problem, the problem is solved, and judging takes no time. Each solution affects the leaderboard, so it also affects the problems other teams attempt.

At every moment, the leaderboard first updates with all solutions that occurred at that moment, and then teams see the updated leaderboard.

Let f(m,i)f(m,i) be the expected number of teams that solve problem ii if mm teams participate in the contest. Let g(i)=lim⁡m→∞f(m,i)mg(i) = \lim_{m \rightarrow \infty} \frac{f(m,i)}{m}, the expected proportion of teams that solve problem ii when the number of teams is large enough. Output g(i)g(i) for every problem ii in the set.

Input

The first line contains two integers nn (1≤n≤171 \le n \le 17) and tt (1≤t≤1001 \le t \le 100), where nn is the number of problems in the contest and tt is the time limit in minutes.

Each of the next nn lines contains two integers rr and cc (1≤r,c≤t1 \le r,c \le t) and one real number pp (0.0≤p≤1.00.0 \le p \le 1.0). Each line describes one problem: rr is the reading time in minutes, cc is the coding time in minutes, and pp is the probability of solving the problem.

Output

Output nn lines. Each line contains one real number: the expected proportion of teams that solve that problem when the number of teams is sufficiently large. Output the proportions for the problems in the same order as the input. Answers are accepted if their absolute or relative error is at most 10−610^{-6}.

Examples3

  1. Example 1

    Input
    4 42
    10 10 0.75
    10 10 0.75
    10 12 1
    10 12 1
    
    Expected output
    0.45625
    0.45625
    0.296875
    0.296875
    
  2. Example 2

    Input
    4 42
    10 12 0.75
    10 12 0.75
    10 10 1
    10 10 1
    
    Expected output
    0.203125
    0.203125
    0.683238636363636
    0.683238636363636
    
  3. Example 3

    Input
    5 100
    40 60 0.6
    40 61 1
    10 40 0.3
    10 40 0.4
    10 40 0.5
    
    Expected output
    0.12
    0
    0.112628571428571
    0.159739682539683
    0.206444444444444