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

The length of the longest common prefix of two strings s=s1s2sn and t=t1t2tm is defined as the maximum integer k0≤k≤min(n,m)) such that s=s1s2sn equals to t=t1t2tm

Koa the Koala initially has n+1 strings s=s1s2sn+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+1which 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


Output


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

首先随便构造一个字符串作为第一个,然后对于每个ai,把上一个字符串下标为ai的字母换掉就得到当前字符串了(可以直接ASCII码减去'a'再加1,再对26取模)。

#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin >> t;
	while(t--)
	{
		int n;
		cin >> n;	
		string s = "";
		for(int i = 0; i < 200; i++) s += 'a';
		cout << s << endl;
		for(int i = 1; i <= n; i++)
		{
			int temp;
			cin >> temp;
			s[temp] = (s[temp] - 'a' + 1) % 26 + 'a';
			cout << s << endl;
		}
	}
	return 0;
}
posted @   脂环  阅读(216)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示
主题色彩