1267: Another String Minimization Problem

内存限制:128 MB 时间限制:1.000 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:5 通过:1 通过率:20%

题目描述

You have a sequence a1,a2,…,an of length n, consisting of integers between 1 and m. You also have a string s, consisting of m characters B.
You are going to perform the following n operations.
  • At the i-th (1 <= i <= n) operation, you replace either the ai-th or the (m+1−ai)-th character of s with A. You can replace the character at any position multiple times through the operations.
Find the lexicographically smallest string you can get after these operations.

A string x is lexicographically smaller than a string y of the same length if and only if in the first position where x and y differ, the string x has a letter that appears earlier in the alphabet than the corresponding letter in y.

输入格式

The first line contains the number of test cases t (1<=t<=2000)。 

The first line of each test case contains two integers n and m (1≤n,m≤50) — the length of the sequence a and the length of the string s respectively.

The second line contains n integers a1,a2,…,an (1≤ai≤m) — the sequence a.

输出格式

For each test case, print a string of length m — the lexicographically smallest string you can get. Each character of the string should be either capital English letter A or capital English letter B.

输入样例 复制

2
4 5
1 1 3 1
1 5
2

输出样例 复制

ABABA
BABBB

数据范围与提示

In the first test case, the sequence a=[1,1,3,1]. One of the possible solutions is the following.

  • At the 1-st operation, you can replace the 1-st character of s with A. After it, s becomes ABBBB.
  • At the 2-nd operation, you can replace the 5-th character of s with A (since m+1−a2=5). After it, s becomes ABBBA.
  • At the 3-rd operation, you can replace the 3-rd character of s with A. After it, s becomes ABABA.
  • At the 4-th operation, you can replace the 1-st character of s with A. After it, s remains equal to ABABA.

分类标签