Soccer Standings
InterviewTime limit1sMemory limit1024 MB
Given each team's games played and points, list every win-tie-loss record that produces those points, sorted by wins in descending order.
- Level
Easy2 of 10
- Topics
- Brute force, Implementation
- Solved
- No attempts yet
Problem
In a soccer match, a team either wins, ties, or loses. A win is worth 3 points, a tie is worth 1 point, and a loss is worth 0 points. Unfortunately, due to poor record-keeping, some leagues have saved only the number of games played and the points each team earned. One league has asked you to write a program that recreates the possible combinations of wins, ties, and losses for certain teams.
Given the number of games a team played in a season and the number of points it earned, list every combination of wins, ties, and losses that gives the team that total.
Input
The first line contains a positive integer n, the number of teams whose records you are to reconstruct. Each of the next n lines describes one team with two space-separated integers g () and p (), the number of games played and the total points earned. It is guaranteed that at least one combination of wins, ties, and losses is consistent with the given information for each team.
Output
For each team, first print the header below, where k is the team number starting at 1, g is the number of games, and p is the total points.
Team #k
Games: g
Points: p
Possible records:
Then print each possible record on its own line in the format w-t-l, where w is the number of wins, t is the number of ties, and l is the number of losses. Sort the records by wins in descending order.
Leave a blank line after the output for each team.