#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 3737 likes, and Xiao Y has 2828 likes. First compare the last digit: Xiao X has 77 and Xiao Y has 88, so Xiao Y is temporarily ahead. Then include the previous digit: Xiao X has 3737 and Xiao Y has 2828, 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 137137 likes and Xiao Y has 4747 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 ss, 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): len(s)=1\text{len}(s) = 1.
  • Subtask 2 (42 points): si{X,Y}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%100\% of the testdata, si{X,Y,Z}s_i \in \{\texttt{X},\texttt{Y},\texttt{Z}\}, 1len(s)1061 \le \text{len}(s) \le 10^6.

Translated by ChatGPT 5