A. Common Prefixes【水题】

Problem - A - Codeforces

The length of the longest common prefix of two strings s=s1s2…sns=s1s2…sn and t=t1t2…tmt=t1t2…tm is defined as the maximum integer kk (0≤k≤min(n,m)0≤k≤min(n,m)) such that s1s2…sks1s2…sk equals t1t2…tkt1t2…tk.

Koa the Koala initially has n+1n+1 strings s1,s2,…,sn+1s1,s2,…,sn+1.

For each ii (1≤i≤n1≤i≤n) she calculated aiai — the length of the longest common prefix of sisi and si+1si+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+1s1,s2,…,sn+1 which would have generated numbers a1,a2,…,ana1,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 tt (1≤t≤1001≤t≤100) — the number of test cases. Description of the test cases follows.

The first line of each test case contains a single integer nn (1≤n≤1001≤n≤100) — the number of elements in the list aa.

The second line of each test case contains nn integers a1,a2,…,ana1,a2,…,an (0≤ai≤500≤ai≤50) — the elements of aa.

It is guaranteed that the sum of nn over all test cases does not exceed 100100.

Output

For each test case:

Output n+1n+1 lines. In the ii-th line print string sisi (1≤|si|≤2001≤|si|≤200), consisting of lowercase Latin letters. Length of the longest common prefix of strings sisi and si+1si+1 has to be equal to aiai.

If there are many answers print any. We can show that answer always exists for the given constraints.

Example

input

Copy

4
4
1 2 4 2
2
5 3
3
1 3 1
3
0 0 0

output

Copy

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]s=[aeren,ari,arousal,around,ari].

Lengths of longest common prefixes are:

  • Between aerenaeren and ariari →1→1
  • Between ariari and arousalarousal →2→2
  • Between arousalarousal and aroundaround →4→4
  • Between aroundaround and ariari →2
  • #include<iostream>
    #include<cstring>
    #include<algorithm>
    #include<vector>
    #include<set>
    #include<map>
    #include<queue>
    #include<deque>
    #include<cmath>
    #include<string.h>
    using namespace std;
    // ctrl+shift+C 注释
    //ctrl+shift+x 取消
    #define int long long
    #define YES cout<<"YES"<<endl;
    #define NO cout<<"NO"<<endl;
    #define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //int k = min_element(a + 1, a + 1 + n) - a
    typedef long long ll;
    typedef pair<int,int> PII;
    const int N=2e5+10;
    const ll M=1e18+10;
    const int mod=1e9+7;
    int a[N],b[N];
    priority_queue<int,vector<int>,greater<int> >pq;
    set<int>se;
    map<int,int>mp;
    queue<int>qu;
    vector<int>v;
    deque<int>de;
    //struct Range
    //{
    //    int l,r;
    //    bool operator< (const Range &w)const
    //    {
    //        return l<w.l;
    //    }
    //}range[N];
    void solve()
    {
        int n;
        cin>>n;
        int maxx=0;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            maxx=max(a[i],maxx);
        }
        string s="y";
        for(int i=1;i<=maxx;i++)
        {
            s+="y";
        }
        cout<<s<<endl;//输出第一个
        for(int i=1;i<=n;i++)
        {
            for(int j=a[i];j<=maxx;j++)//后面的变
            {
                if(s[j]!='y')
                 s[j]-=1;
                 else s[j]+=1;
            }
            cout<<s<<endl;
        }
    }
    signed main()
    {
       int t=1;
       cin>>t;
       while(t--)
       {
           solve();
       }
    }
    

    细心点,相信自己

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值