eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

The Diputs notation

The Diputs notation

The Diputs notation is a notation to represent non-negative integer numbers. Diputs notation has \textbf{9} digits, starting with the least significant: \textbf{_.,-~='^} There can be a limited quantity of each digit character in the number representation: A number representation in Diputs notation starts with the most significant digit, e.g.: \textbf{"""^^~~-,..__} Let us write down all possible number representations in Diputs notation and arrange them in the following order. Number \textbf{A} goes after number \textbf{B} if the representation of \textbf{A} in Diputs notation has more `"` (most significant digit) characters than the representation of \textbf{B}. If the numbers \textbf{A} and \textbf{B} have equal number of `"` characters, we then compare the number of '^' characters, and so on. Then we number this sequence, starting from 1 - and the result is the map which defines how numbers are represented in Diputs notation. Zero is represented with the 'O' character (code 79). Examples: \InputFile There is an input containing numbers in decimal notation, numbers in Diputs notation, and some other text. \OutputFile You must output the same numbers, but in another notation: the numbers in decimal notation should be converted to Diputs notation, and the numbers in Diputs notation should be converted to decimals. All numbers in the input are non-negative and do not exceed maximum number representable in Diputs notation. It is possible that the numbers will not be separated by space or other characters. You should parse the numbers in greedy way: when reading a number, you should take maximum number of characters that can form a decimal or Diputs representation of a number. For example, if you have three underscore characters ("\textbf{___}"), you should parse it as numbers "\textbf{__}" (\textbf{2}) and "\textbf{_}" (\textbf{1}) in Diputs notation. In this case, the resulting string will be "\textbf{21}". When parsing decimal numbers, your program should work the same way. There should be no leading zeros in decimal numbers. For example, you should parse the string "\textbf{020}" as decimal numbers \textbf{0} and \textbf{20}, and the result will be "\textbf{O,..__}". If you would get a decimal number larger than the maximum number representable in Diputs notation, you should split it into two or more decimal numbers in greedy way, as described. \textit{\textbf{Some examples}}: Because we feel that your task is too easy, you should sort the numbers in ascending order, if the total number of numbers in the input is odd. Only numbers should be reordered; the notation of a number in a certain location should not be changed. For example, for input "\textbf{2 O _}" you should first recognize the notation (decimal, diputs, diputs), then convert it to "\textbf{__ 0 1}", inverting the notation (it is now diputs, decimal, decimal), and then sort the numbers while preserving the notation. Thus, the sorted array is \textbf{0}, \textbf{1} and \textbf{2}, the notations are (diputs, decimal, decimal), so the answer should be "\textbf{O 1 2}". Take a look at the sample input for better understanding. Size of input and output will not exceed \textbf{1} megabyte (\textbf{10^6} bytes).
Ліміт часу 0.5 секунд
Ліміт використання пам'яті 256 MiB
Вхідні дані #1
need 2 sort
O
_
Вихідні дані #1
need O sort
1
2
Джерело Izhevsk STU Contest, Petrozavodsk training camp, February 6, 2009