#P9791. Volleyball Match Score Reconstruction

    ID: 22937 Type: Default 1000ms 256MiB

Volleyball Match Score Reconstruction

Volleyball Match Score Reconstruction

Alice loves watching volleyball matches – especially when team A plays. In a volleyball match, the rules are as follows:

  • A match consists of at most \(5\) sets.
  • In the first 4 sets, a team must score at least \(25\) points to win the set; in the 5th set, only \(15\) points are needed.
  • If in any set one team satisfies the winning condition but the point difference is less than \(2\), then the set is not won.
  • The match immediately ends when one team wins \(3\) sets.

You are given the number of sets won by team A and team B. Your task is to determine the best possible complete match score for team A according to the following definition:

Note: The best score is defined as follows. If team A wins the match (i.e. wins exactly \(3\) sets while team B wins between \(0\) and \(2\) sets), then among all valid match score reconstructions, you should choose the one that maximizes the overall total point difference \(\Delta = (\text{total points of A}) - (\text{total points of B})\). Conversely, if team A loses (i.e. team B wins exactly \(3\) sets and team A wins between \(0\) and \(2\) sets), you should choose the reconstruction that minimizes the loss (i.e. makes \(\Delta\) as high as possible, though negative).

To achieve this:

  • If team A wins a set, you want the winning margin to be as large as possible. In valid scores, a non-5th set win can be recorded as 25:0 and a 5th set win as 15:0.
  • If team A loses a set, you want the lost set to be as close as possible. In a non-5th lost set the best possible score for A is 23:25 (since a score like 24:26 is valid too but both yield a margin of \(-2\)), and in a 5th set loss you may use 14:16 in wins or, for the purpose of maximizing A's total, you may use slightly higher numbers. In our solutions for losing matches we choose scores so that A's winning sets are recorded as 25:23 (margin +2) and A's lost sets as 24:26 (margin \(-2\)) in non-5th sets and 15:17 in the 5th set.

The match outcome must obey the following possibilities:

  • If team A wins the match, the valid outcomes are \(3:0\), \(3:1\), or \(3:2\) (i.e. team B wins 0, 1, or 2 sets respectively).
  • If team A loses the match, the valid outcomes are \(0:3\), \(1:3\), or \(2:3\) (i.e. team A wins 0, 1, or 2 sets respectively).
  • If neither team has reached 3 wins the match is considered to be still in progress.

Your program should print the sequence of set scores (each in the format X:Y) separated by a space if a valid complete match result exists; otherwise, print Match has not ended. If the given wins for team A and team B cannot correspond to any valid complete match, print Impossible.


Examples:

Input: 3 0
Output: 25:0 25:0 25:0

Input: 3 1 Output: 25:0 25:0 23:25 25:0

Input: 1 3 Output: 24:26 25:23 24:26 24:26

Input: 3 2 Output: 25:0 25:0 23:25 23:25 15:0

Input: 2 3 Output: 25:23 24:26 25:23 24:26 15:17

Input: 2 2 Output: Match has not ended

</p>

inputFormat

The input consists of a single line with two space-separated integers \(a\) and \(b\), where \(a\) is the number of sets won by team A and \(b\) is the number of sets won by team B.

Constraints:

  • \(0 \leq a, b \leq 3\)

outputFormat

If a valid complete match result corresponding to the given wins exists, output the set scores separated by a space. Otherwise, if the match has not ended (i.e. both teams have less than 3 wins), output Match has not ended. In cases where the wins combination is impossible, output Impossible.

sample

3 0
25:0 25:0 25:0