#P6458. [COCI 2006/2007 #5] LIGA
[COCI 2006/2007 #5] LIGA
Problem Description
There are teams participating in a tournament. Each team has values: total matches played, number of wins, number of draws, number of losses, and points. Each win gives points, each draw gives point, and losses give points.
However, because the table was damaged, some values are unreadable (shown as ?). You need to infer the missing values from the other data and restore the table.
It is known that each team plays at most matches. It is guaranteed that each damaged entry has exactly one original value that matches it.
Note that the win counts of all teams may not match the tournament logic. You may treat each team as an independent individual.
Input Format
The first line contains an integer , the number of teams.
The next lines each contain integers or ?, in order: total matches played, wins, draws, losses, and points.
Output Format
Output lines. Each line contains integers, the fully restored table.
A unique solution is guaranteed.
5
27 21 3 3 66
27 18 6 3 ?
? 15 5 7 50
? 14 7 5 ?
? 14 ? 8 47
27 21 3 3 66
27 18 6 3 60
27 15 5 7 50
26 14 7 5 49
27 14 5 8 47
Hint
Constraints
For of the testdata, .
Notes
Translated from COCI2006-2007 CONTEST #5 T4 LIGA。
Translated by ChatGPT 5