Morse Code
시간 제한2초메모리 제한2048 MB
가중치가 있는 n개 문자에 접두사 없는 점·선 부호를 배정해 전송 시간의 가중 합(선은 점의 두 배)을 최소로 만든다.
문제
Morse code is a classical way to communicate over long distances, but there are some drawbacks that increase the transmission time of long messages.
In Morse code, each character in the alphabet is assigned a sequence of dots and dashes such that no sequence is a prefix of another. To transmit a string of characters, the sequences corresponding to each character are sent in order. A dash takes twice as long to transmit as a dot.
Your alphabet has characters, where the -th character appears with frequency in your language. Your task is to design a Morse code encoding scheme, assigning a sequence of dots and dashes to each character, that minimizes the expected transmission time for a single character. In other words, you want to minimize , where is the time required to transmit the sequence of dots and dashes assigned to the -th character.
입력
The first line contains an integer () — the number of characters in the alphabet.
The second line contains real numbers () — is the frequency of the -th character. All values are given with exactly four digits after the decimal point. The sum of all frequencies is exactly .
출력
Print lines, each containing one string consisting of dots . and dashes -. The -th line corresponds to the sequence of dots and dashes that you assign to the -th character.
If there are multiple valid assignments with the minimum possible expected transmission time, any of them is considered correct.