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

17570번 - Fibonacci Compression 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB50242363.889%

문제

Fibonacci compression is a new type of fault-tolerant compression based on Fibonacci numbers. Symbols are constructed according to the rule that no code word may have two consecutive “1” bits at any place other than the end, where they are mandatory. In practice this means that, for each compressed symbol bit-length i where i ≥ 2, there are Fibonacci(i − 1) compressed symbols of that length.

For example, the shortest 14 Fibonacci code words are as follows:

11 011 0011 1011
00011 10011 01011 000011
100011 010011 001011 101011
0000011 1000011 ...

Compressing a string using Fibonacci compression works by replacing the most frequent characters with the shortest codes. Given one such string s, find the length of each of its prefixes when compressed as small as possible according to this system.

입력

  • One line containing the length of the string to compress, n (1 ≤ n ≤ 105).
  • One line containing the string s as a sequence of n integers si (0 ≤ si ≤ 106).

출력

Output |s| lines, where the ith line is the compressed length of the first i characters of s, in bits.

제한

예제 입력 1

4
97 97 98 98

예제 출력 1

2 4 7 10

예제 입력 2

24
1 75 2 1 1 75 75 75 75 75 75 2 2 3 4 5 6 7 8 9 10 11 12 10

예제 출력 2

2 5 9 11 13 16 19 21 23 25 27 31 35 39 44 49 54 60 66 72 78 84 91 95

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > The UK & Ireland Programming Contest > UKIEPC 2018 F번

  • 문제를 만든 사람: Robin Lee
  • 문제의 오타를 찾은 사람: lobo_prix
(追記) (追記ここまで)

출처

대학교 대회

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

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