Fire Control - 2
Medium
Execution time limit is 0.1 seconds
Runtime memory usage limit is 16 megabytes
In the context of the previous problem, where a message—an integer ranging from 0 to 1000000—is encrypted by repeating each digit as many times as its value, write a program to decrypt the message.
The program should return the original message if it has been received without errors, or -1 if it cannot be restored.
Input
The input to the program is the received encrypted message S, which is an integer (0 ≤ S < 10^60).
Output
The program should output the original message P, which is an integer (0 ≤ P ≤ 1000000), or -1 if the message cannot be accurately reconstructed.
Examples
Input #1
Answer #1
Submissions 2K
Acceptance rate 5%