P5595 [XR-4] Singing Contest
Background
**In-contest reminder: This problem provides no explanation for sample 4 or for the no-solution cases.**
**In-contest reminder: This problem provides no explanation for the output format or the Special Judge.**
**In-contest reminder: Sorry, the Special Judge for this problem does not ignore trailing spaces. Please make sure there are no extra characters in the two lines.**
**In-contest reminder: Very sorry, the input data of this problem uses Windows line endings instead of Linux line endings, so there is an extra `\r` character before the ending `\n`. Please use `scanf` or `cin` to read the data instead of `getline`, because the latter will read an extra `\r`.**
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 $37$ likes, and Xiao Y has $28$ likes. First compare the last digit: Xiao X has $7$ and Xiao Y has $8$, so Xiao Y is temporarily ahead. Then include the previous digit: Xiao X has $37$ and Xiao Y has $28$, 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 $137$ likes and Xiao Y has $47$ 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 $s$, 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`.
Explanation/Hint
**This problem uses bundled tests.**
- Subtask 1 (11 points): $\text{len}(s) = 1$.
- Subtask 2 (42 points): $s_i \in \{\texttt{X},\texttt{Y}\}$.
- Subtask 3 (21 points): The testdata guarantees that a solution exists.
- Subtask 4 (26 points): No special restrictions.
For $100\%$ of the testdata, $s_i \in \{\texttt{X},\texttt{Y},\texttt{Z}\}$, $1 \le \text{len}(s) \le 10^6$.
Translated by ChatGPT 5