시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 256 MB | 173 | 162 | 156 | 93.413% |
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.
For example, the following is how the transform above works on the string hakka.
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).
3 5 7 1 10 0 1 6 1 1 13 1 1 1 8 7 1 1 1 20 4 0 1
hakka banana hahauccu
ICPC > Regionals > Asia Pacific > Taiwan > Taiwan Online Programming Contest > TOPC 2015 B번