RoAlgo Contest #8 | SuperLiga

This was the problem page during the contest. Access the current page here.
Time limit: 0.5s Memory limit: 256MB Input: Output:

Task

A ranking line of the form (M,V,E,I,P)(M, V, E, I, P) — (matches, victories, draws, defeats, points) is given, where some of the values may be denoted with a question mark (??) but not MM. This ranking line corresponds to the results of a team throughout a competitive season in a football league in Southeast Europe.

Now B.B.C, a specialist in the field, wants to know if we can obtain a configuration starting from the current configuration that is valid according to football rules (33 points for a victory, 11 point for a draw, 00 points for defeats), or if it is impossible. This can be done by replacing the question marks with natural numbers.

For example, the configuration (5,?,1,?,10)(5, ?, 1, ?, 10) is valid because we can obtain the configuration (5,3,1,1,10)(5, 3, 1, 1, 10)33 victories, 11 draw, and 11 defeat.

Note that the number of matches is always known.

Input data

The first line will contain the number of tests TT.

Each of the next TT lines will contain a configuration in the format described in the statement, each of the 55 positions can contain either the character ? or a natural number, representing the corresponding number for that position.

Output data

Each line will contain either a valid configuration starting from the given input configuration or the message Impossible if it is not possible.

Any valid configuration is accepted.

Constraints and clarifications

  • 1T1051 \leq T \leq 10^5
  • 0M,V,E,I,P1070 \leq M, V, E, I, P \leq 10^7
# Score Constraints
1 0 Example
2 13 Only one variable is unknown and M300M \leq 300
3 13 The number of points is always unknown and M300M \leq 300
4 20 M300M \leq 300
5 13 Only one variable is unknown
6 13 The number of points is always unknown
7 28 No additional constraints

Example

stdin

17
5 ? ? ? ?
9 4 ? 4 ?
7 ? ? 5 4
4 1 2 1 6
6 3 ? 4 12
9 ? 4 ? 13
14 5 ? ? 13
58 28 ? ? 94
100 ? ? 43 120
10 ? ? ? ?
10 4 3 3 ?
10 4 3 ? ?
10 4 ? 3 ?
10 4 ? ? ?
10 ? 3 3 ?
10 ? 3 ? ?
10 ? ? 3 ?

stdout

5 0 0 5 0
9 4 1 4 13
7 1 1 5 4
Impossible
Impossible
9 3 4 2 13
Impossible
58 28 10 20 94
Impossible
10 0 0 10 0
10 4 3 3 15
10 4 3 3 15
10 4 3 3 15
10 4 0 6 12
10 4 3 3 15
10 0 3 7 3
10 0 7 3 7

Log in or sign up to be able to send submissions!