The length of the longest common prefix of two strings s=s1s2…sn and t=t1t2…tm is defined as the maximum integer k (0≤k≤min(n,m)) such that s1s2…skequals t1t2…tk.
Koa the Koala initially has n+1 strings s1,s2,…,sn+1.
For each i (1≤i≤n) she calculated ai — the length of the longest common prefix of si and si+1.
Several days later Koa found these numbers, but she couldn't remember the strings.
So Koa would like to find some strings s1,s2,…,sn+1 which would have generated numbers a1,a2,…,an. Can you help her?
If there are many answers print any. We can show that answer always exists for the given constraints.
Input
Each test contains multiple test cases. The first line contains t (1≤t≤100) — the number of test cases. Description of the test cases follows.
The first line of each test case contains a single integer n (1≤n≤100) — the number of elements in the list a.
The second line of each test case contains n integers a1,a2,…,an (0≤ai≤50) — the elements of a.
It is guaranteed that the sum of n over all test cases does not exceed 100.
Output
For each test case:
Output n+1 lines. In the i-th line print string si (1≤|si|≤200), consisting of lowercase Latin letters. Length of the longest common prefix of strings si and si+1 has to be equal to ai.
If there are many answers print any. We can show that answer always exists for the given constraints.
Example
input
4 4 1 2 4 2 2 5 3 3 1 3 1 3 0 0 0
output
aeren ari arousal around ari monogon monogamy monthly kevinvu kuroni kurioni korone anton loves adhoc problems
Note
In the 11-st test case one of the possible answers is s=[aeren,ari,arousal,around,ari].
Lengths of longest common prefixes are:
Between aerenand ari→1
Between ari and arousal→2
Between arousal and around→4
Between around and ari →2
题意:
给定一个长度为n的数组,需要构造出n+1个字符串,使得第一个字符串和第二个字符串的相同前缀长度为数组中第一个元素,第二个字符串和第三个字符串的相同前缀长度为数组中第二个元素,以此类推。
这个题目的做法很难想。
由于和最长前缀长度有关,我们记录下数组中最大的数,记其为maxn。
我们发现,如果第一个字符串确定了,那我们便可以依次修改,以达到目的。使用a和b来区分是否相同。初始化第一个字符串为长度为maxn+1的全为a的字符串。
#include
using namespace std;
int a[110];
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int maxn=0xc0c0c0c0;
for(int i=1;i<=n;i++)
{
cin>>a[i];
maxn=max(maxn,a[i]);
}
string s(maxn+1,'a');
cout<