#P5595. 【XR-4】歌唱比赛
【XR-4】歌唱比赛
Description
Xiao X took part in a singing contest.
After a hard fight, Xiao X finally made it to the final, and his opponent is Xiao Y.
The champion of this singing contest is decided by the number of likes: whoever has more likes wins.
After Xiao X and Xiao Y sang their last song in turn, their final numbers of likes were fixed.
The moment to announce the champion finally arrived. To build suspense, the host decided to compare their numbers of likes starting from the last digit, moving left one digit at a time.
For example, Xiao X has likes, and Xiao Y has likes. First compare the last digit: Xiao X has and Xiao Y has , so Xiao Y is temporarily ahead. Then include the previous digit: Xiao X has and Xiao Y has , so Xiao X is temporarily ahead. After the comparison ends, if we use X to represent “Xiao X is temporarily ahead” and Y to represent “Xiao Y is temporarily ahead”, we can write down a string XY.
For another example, Xiao X has likes and Xiao Y has likes. If we additionally use Z to represent “Xiao X and Xiao Y are temporarily equal”, then the written string should be XYZ.
As someone who is good at OI, you of course know that this comparison method is not scientific at all—it just wastes time. However, you are very interested in the final string that is written down.
Now you are given this final string, and you need to construct one possible pair of like counts for Xiao X and Xiao Y.
Of course, it is possible that no pair of like counts can match this string. In that case, you only need to output -1.
To make output easier, please use leading zeros to pad the number of digits.
Input Format
One line with a string , representing the final written string.
Output Format
If there is a solution:
- The first line contains an integer, the number of likes for Xiao X.
- The second line contains an integer, the number of likes for Xiao Y.
If there is no solution:
- One line with an integer
-1.
XY
37
28
XYZ
137
047
ZZZZZZ
000000
000000
XYZXYZ
-1
Hint
This problem uses bundled tests.
- Subtask 1 (11 points): .
- Subtask 2 (42 points): .
- Subtask 3 (21 points): The testdata guarantees that a solution exists.
- Subtask 4 (26 points): No special restrictions.
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号