#P9791. [NERC 2018] Alice the Fan
[NERC 2018] Alice the Fan
Background
Translated from Problem A of NERC 2018.
Problem Description
Alice likes watching volleyball matches, and she especially likes watching Team A. The rules of a volleyball match are as follows:
-
A match has at most sets.
-
In the first sets, a team must score at least points to win the set. In the th set, only points are required.
-
If, within a set, one side meets the winning condition but the score difference between the two sides is less than , it is not considered a win.
-
A team that wins sets wins the match, and the match ends immediately at that moment.
Now you are given the numbers of sets won by Team A and Team B, and you need to determine the best possible match score for Team A, or determine that the match has not ended yet.
(Note: In this problem, the “best” match score is defined as follows: if Team A can win, make the difference in the number of sets between the two teams as large as possible; otherwise, make it as small as possible.)
Input Format
The first line contains an integer , indicating that Team A has played different matches.
The next lines each contain two integers and , representing the points scored by Team A and Team B in that match.
Output Format
For each match, output Team A’s best match score situation and one set-by-set score sequence that satisfies the conditions, or determine that it is impossible and output Impossible.
6
75 0
90 90
20 0
0 75
78 50
80 100
3:0
25:0 25:0 25:0
3:1
25:22 25:22 15:25 25:21
Impossible
0:3
0:25 0:25 0:25
3:0
25:11 28:26 25:13
3:2
25:17 0:25 25:22 15:25 15:11
Hint
The testdata guarantees that and .
Note: Due to technical reasons, if the SPJ shows UKE during judging, it is because there is an error in your code, causing the SPJ to read one more or one fewer character, and then it cannot judge normally.
Translated by ChatGPT 5