Inconstant Ordering
시간 제한10초메모리 제한1024 MB
블록 길이가 주어질 때 A로 시작하고 각 블록이 교대로 엄격히 증가하거나 감소하는 사전순 최소 문자열을 만든다.
문제
We want to build a string with English alphabet uppercase letters in sorted order. However, we want the order to be sometimes strictly increasing and sometimes strictly decreasing.
The first letter of the string must be A. After that, the string must contain one or more blocks of letters. The -th block must contain exactly letters. Each letter in the -th block must be later in the alphabet than its preceding letter in the string if is odd and earlier in the alphabet than its preceding letter if is even. Notice that for the first letter of a block, its preceding letter exists, even though it is not in the block. Strings that follow all of these rules are called valid. There can be multiple valid strings, and we want to find the alphabetically first one.
For example, if there are blocks of sizes and , the string must have exactly letters (the is for the initial A). The strings XYZYBA, AZYCBA and AYZYBB are not valid for this case because they violate the required starting letter condition, and the ordering conditions in the first and second block, respectively. The string AYZYBA is valid. The string ABDCBA is also valid and, moreover, it is the alphabetically first valid string.
Given the sizes of the blocks, output the valid string that comes first in alphabetical order in the list of all valid strings. It can be shown that, for all inputs within the given limits, at least one valid string exists.
입력
The first line of the input gives the number of test cases, . test cases follow. Each test case is described with two lines. The first line of a test case contains a single integer , the number of blocks. The second line contains integers , the number of letters each block must have, in order.
출력
For each test case, output one line containing Case #x: y, where is the test case number (starting from 1) and is the valid string that comes first in alphabetical order. It is guaranteed that at least one valid string exists.
제한
- .
- , for all .