Leaderboard Effect
Time limit3sMemory limit1024 MB
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:
- 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 , , and solutions, respectively, they choose A with probability , B with probability , and C with probability .
- 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 be the expected number of teams that solve problem if teams participate in the contest. Let , the expected proportion of teams that solve problem when the number of teams is large enough. Output for every problem in the set.
Input
The first line contains two integers () and (), where is the number of problems in the contest and is the time limit in minutes.
Each of the next lines contains two integers and () and one real number (). Each line describes one problem: is the reading time in minutes, is the coding time in minutes, and is the probability of solving the problem.
Output
Output 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 .