Logo
(追記) (追記ここまで)

33600번 - Morse Code 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 2048 MB32151368.421%

문제

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 $n$ characters, where the $i$-th character appears with frequency $f_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 + \cdots + f_nt_n,ドル where $t_i$ is the time required to transmit the sequence of dots and dashes assigned to the $i$-th character.

입력

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

The second line contains $n$ real numbers $f_1, f_2, \dots , f_n$ (0ドル < f_i < 1$) — $f_i$ is the frequency of the $i$-th character. All values $f_1, f_2, \dots , f_n$ are given with exactly four digits after the decimal point. The sum of all frequencies is exactly 1ドル$.

출력

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

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

제한

예제 입력 1

3
0.3000 0.6000 0.1000

예제 출력 1

-.
.
--

The alphabet contains three letters, say $a,ドル $b,ドル and $c,ドル with respective frequencies 0ドル.3,ドル 0ドル.6,ドル and 0ドル.1$. In the optimal assignment, we assign $a$ to ‘-.’, $b$ to ‘.’, and $c$ to ‘-’. This gives an expected transmission time of 0ドル.3 \cdot 3 + 0.6 \cdot 1 + 0.1 \cdot 4 = 1.9$ time units per character, which is optimal.

For comparison, the assignment $a$ → ‘..’, $b$ → ‘-’, $c$ → ‘.-’ has an expected transmission time of 0ドル.3 \cdot 2 + 0.6 \cdot 2 + 0.1 \cdot 3 = 2.1$. The assignment $a$ → ‘-’, $b$ → ‘.’, $c$ → ‘..’ has a lower expected transmission time, but is invalid since ‘.’ is a prefix of ‘..’.

예제 입력 2

3
0.3000 0.4500 0.2500

예제 출력 2

..
-
.-

힌트

출처

ICPC > Regionals > Europe > European Championship > The 2025 ICPC European Championship D번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /