#P6458. [COCI 2006/2007 #5] LIGA

[COCI 2006/2007 #5] LIGA

Problem Description

There are nn teams participating in a tournament. Each team has 55 values: total matches played, number of wins, number of draws, number of losses, and points. Each win gives 33 points, each draw gives 11 point, and losses give 00 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 100100 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 nn, the number of teams.

The next nn lines each contain 55 integers or ?, in order: total matches played, wins, draws, losses, and points.

Output Format

Output nn lines. Each line contains 55 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 100%100\% of the testdata, 1n10001\le n\le 1000.

Notes

Translated from COCI2006-2007 CONTEST #5 T4 LIGA

Translated by ChatGPT 5