P8044 [COCI 2015/2016 #4] YODA
Background
A long, long time ago, in a galaxy far, far away, a giant integer collision was taking place.
Description
What happens when two integers collide? First, keep adding leading $0$ digits to the front of the number with fewer digits until both numbers have the same number of digits. Then, starting from the least significant digit, compare the corresponding digits of the two numbers each time, and delete the smaller digit (if the two digits are equal, **do nothing**). Repeat this process toward higher digits until the most significant digit.
After that, concatenate (in order) the digits that were not deleted in each number to form two new numbers.
For example, for $456328$ and $284315$, the collision process is as follows:
| $4$ | $\sout{~5~}$ | $6$ | $3$ | $2$ | $8$ |
| :-: | :-: | :-: | :-: | :-: | :-: |
| $\sout{~2~}$ | $8$ | $\sout{~4~}$ | $3$ | $\sout{~1~}$ | $\sout{~5~}$ |
It is easy to see that after the collision, the two new numbers are $46328$ and $83$.
Now given two numbers $n, m$, find the new numbers obtained after they collide. If a number has all its digits deleted after the collision, output the string `YODA` on its line. See the Output Format section for details.
Input Format
The first line contains an integer $n$, the first number to collide.
The second line contains an integer $m$, the second number to collide.
Output Format
Output two lines.
On the first line, if all digits of $n$ have been deleted, output the string `YODA`; otherwise output an integer, the new number obtained from $n$ after the collision.
On the second line, if all digits of $m$ have been deleted, output the string `YODA`; otherwise output an integer, the new number obtained from $m$ after the collision.
Explanation/Hint
**[Sample Explanation 2]**
For sample $2$, the collision process of the two numbers is as follows:
| $6$ | $\sout{~5~}$ | $7$ | $\sout{~4~}$ | $3$ |
| :----------: | :----------: | :----------: | :----------: | :----------: |
| $\sout{~0~}$ | $9$ | $\sout{~6~}$ | $5$ | $\sout{~1~}$ |
Therefore, after the collision, the two new numbers are $673$ and $95$.
**[Constraints]**
For $30\%$ of the testdata, $n$ and $m$ are guaranteed to be three-digit numbers.
For all testdata, $1 \leqslant n, m \leqslant 10^9$.
**[Source]**
This problem comes from **_[COCI 2015-2016](https://hsin.hr/coci/archive/2015_2016/) [CONTEST 4](https://hsin.hr/coci/archive/2015_2016/contest4_tasks.pdf) T1 YODA_**. Using the original testdata configuration, the full score is $50$ points.
Translated and organized by [Eason_AC](https://www.luogu.com.cn/user/112917).
Translated by ChatGPT 5