CF1384A.Common Prefixes

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The length of the longest common prefix of two strings s=s1s2sns = s_1 s_2 \ldots s_n and t=t1t2tmt = t_1 t_2 \ldots t_m is defined as the maximum integer kk ( 0kmin(n,m)0 \le k \le min(n,m) ) such that s1s2sks_1 s_2 \ldots s_k equals t1t2tkt_1 t_2 \ldots t_k .

Koa the Koala initially has n+1n+1 strings s1,s2,,sn+1s_1, s_2, \dots, s_{n+1} .

For each ii ( 1in1 \le i \le n ) she calculated aia_i — the length of the longest common prefix of sis_i and si+1s_{i+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+1s_1, s_2, \dots, s_{n+1} which would have generated numbers a1,a2,,ana_1, a_2, \dots, a_n . Can you help her?

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

输入格式

Each test contains multiple test cases. The first line contains tt ( 1t1001 \le t \le 100 ) — the number of test cases. Description of the test cases follows.

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

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n ( 0ai500 \le a_i \le 50 ) — the elements of aa .

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

输出格式

For each test case:

Output n+1n+1 lines. In the ii -th line print string sis_i ( 1si2001 \le |s_i| \le 200 ), consisting of lowercase Latin letters. Length of the longest common prefix of strings sis_i and si+1s_{i+1} has to be equal to aia_i .

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

输入输出样例

  • 输入#1

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

    输出#1

    aeren
    ari
    arousal
    around
    ari
    monogon
    monogamy
    monthly
    kevinvu
    kuroni
    kurioni
    korone
    anton
    loves
    adhoc
    problems

说明/提示

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 aeren\color{red}{a}eren and ari\color{red}{a}ri 1\rightarrow 1
  • Between ari\color{red}{ar}i and arousal\color{red}{ar}ousal 2\rightarrow 2
  • Between arousal\color{red}{arou}sal and around\color{red}{arou}nd 4\rightarrow 4
  • Between around\color{red}{ar}ound and ari\color{red}{ar}i 2\rightarrow 2
首页