luogu#P8044. [COCI 2015/2016 #4] YODA
[COCI 2015/2016 #4] YODA
Background
A long, long time ago, in a galaxy far, far away, a giant integer collision was taking place.
Problem Description
What happens when two integers collide? First, keep adding leading 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 and , the collision process is as follows:
It is easy to see that after the collision, the two new numbers are and .
Now given two numbers , 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 , the first number to collide.
The second line contains an integer , the second number to collide.
Output Format
Output two lines.
On the first line, if all digits of have been deleted, output the string YODA; otherwise output an integer, the new number obtained from after the collision.
On the second line, if all digits of have been deleted, output the string YODA; otherwise output an integer, the new number obtained from after the collision.
300
500
0
500
65743
9651
673
95
2341
6785
YODA
6785
Hint
[Sample Explanation 2]
For sample , the collision process of the two numbers is as follows:
Therefore, after the collision, the two new numbers are and .
[Constraints]
For of the testdata, and are guaranteed to be three-digit numbers.
For all testdata, .
[Source]
This problem comes from COCI 2015-2016 CONTEST 4 T1 YODA. Using the original testdata configuration, the full score is points.
Translated and organized by Eason_AC.
Translated by ChatGPT 5