Codeforces Round #659 (Div. 2) A. Common Prefixes

A. Common Prefixes

time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output 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…sk equals 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 1-st test case one of the possible answers is s=[aeren,ari,arousal,around,ari].

Lengths of longest common prefixes are:

Between aeren and ari →1
Between ari and arousal →2
Between arousal and around →4
Between around and ari →2

题意

相邻两个字符串之间前缀相同的数目为已知,写出这些字符串。

代码:

#include<iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <functional>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <algorithm>
#define ll long long
#define PI acos(-1)
#define mes(x,y) memset(x,y,sizeof(x))
#define lp pair<ll, ll>
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

ll n, m, i, j, k, t;
const ll INF = 5e6 + 30;
string s, s1, s2;

int main() {
	FAST_IO;
	while (cin >> k) {
		while (k--) {
			cin >> n;
			int a[105];
			for (i = 1; i <= n; i++)cin >> a[i];
			for (i = 0, s = ""; i < 51; i++)s += "a";
			cout << s << endl;
			for (i = 1; i <= n; i++) {
				s[a[i]] = s[a[i]] == 'a' ? 'z' : 'a';
				cout << s << endl;
			}
		}
	}
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

GUESSERR

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值