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

11007번 - Inverse Move-to-Front Transform 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 256 MB26023921591.489%

문제

The Move-to-Front (MTF) transform is an encoding scheme which maps the input data into a sequence of numbers. Entropy encoding schemes often achieve better compression ratio on the data encoded by the MTF transform. The MTF transform is quite simple. The following scheme is the MTF transform on string consisting of only characters in lowercase.

  1. Maintain a list of characters in lowercase. Initially, the list is sorted in the lexicographic order. I.e., the list is [abcdefghijklmnopqrstuvwxyz] at the beginning.
  2. Read a character α from the string. Output the index of α in the list, then move α to the front of the list.
  3. Repeat the previous step until all characters in the string are read.

For example, the following is how the transform above works on the string hakka.

  1. The first character h has index 7 in [abcdefghijklmnopqrstuvwxyz]. Output 7, then move h to the front of the list.
  2. The second character a has index 1 in [habcdefgijklmnopqrstuvwxyz]. Output 1, then move a to the front of the list.
  3. The third character k has index 10 in [ahbcdefgijklmnopqrstuvwxyz]. Output 10, then move k to the front of the list.
  4. The fourth character k has index 0 in [kahbcdefgijlmnopqrstuvwxyz]. Output 0, then move k to the front of the list.
  5. The fourth character a has index 1 in [kahbcdefgijlmnopqrstuvwxyz]. Output 1, then move a to the front of the list.

The MTF transform maps hakka into the sequence (7, 1, 10, 0, 1). Please write a program to inverse the MTF transform. In other words, your program reads a sequence of numbers (a1,...,an), then compute the string s such that the MTF transform maps s into (a1,...,an).

입력

The first line of the input contains an integer T, T ≤ 50, which indicates the number of test cases. Each test case consists of two lines. The first one contains a positive integer n, 1 ≤ n ≤ 100, which indicates the length of the sequence. The second line contains n integers a1,...,an separated by blanks. The input sequence is (a1,...,an), and ai ∈ {0, 1,..., 25} for i ∈ {1,...,n}.

출력

For each test case, output the string s such that the MTF transform maps s into (a1,...,an).

제한

예제 입력 1

3
5
7 1 10 0 1
6
1 1 13 1 1 1
8
7 1 1 1 20 4 0 1

예제 출력 1

hakka
banana
hahauccu

힌트

출처

ICPC > Regionals > Asia Pacific > Taiwan > Taiwan Online Programming Contest > TOPC 2015 B번

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

출처

대학교 대회

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

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