Morse Code

시간 제한2초메모리 제한2048 MB

요약
가중치가 있는 n개 문자에 접두사 없는 점·선 부호를 배정해 전송 시간의 가중 합(선은 점의 두 배)을 최소로 만든다.
난이도

보통10점 중 7점

유형
그리디, 트리, 동적 계획법, 조합론
정답자
아직 제출이 없습니다

문제

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 nn characters, where the ii-th character appears with frequency f_if\_i 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 f_1t_1+f_2t_2+⋯+f_nt_nf\_1t\_1 + f\_2t\_2 + \cdots + f\_nt\_n, where t_it\_i is the time required to transmit the sequence of dots and dashes assigned to the ii-th character.

입력

The first line contains an integer nn (2≤n≤2002 ≤ n ≤ 200) — the number of characters in the alphabet.

The second line contains nn real numbers f_1,f_2,…,f_nf\_1, f\_2, \dots , f\_n (0<f_i<10 < f\_i < 1) — f_if\_i is the frequency of the ii-th character. All values f_1,f_2,…,f_nf\_1, f\_2, \dots , f\_n are given with exactly four digits after the decimal point. The sum of all frequencies is exactly 11.

출력

Print nn lines, each containing one string consisting of dots . and dashes -. The ii-th line corresponds to the sequence of dots and dashes that you assign to the ii-th character.

If there are multiple valid assignments with the minimum possible expected transmission time, any of them is considered correct.

예제2

  1. 예제 1

    입력
    3
    0.3000 0.6000 0.1000
    
    예상 출력
    -.
    .
    --
    
  2. 예제 2

    입력
    3
    0.3000 0.4500 0.2500
    
    예상 출력
    ..
    -
    .-