GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Monday 18 July 2022

[Solution] Another String Minimization Problem Codeforces Solution



A. Another String Minimization Problem
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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 (1in) operation, you replace either the ai-th or the (m+1ai)-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

Solution Click Below:-  👉CLICK HERE

 position where x and y differ, the string x has a letter that appears earlier in the alphabet than the corresponding letter in y.

Input

The first line contains the number of test cases t (1t2000).

Another String Minimization Problem Codeforces Solution

Making Towers Codeforces Solution

Qpwoeirut And The City Codeforces Solution

Chopping Carrots (Easy Version) Codeforces Solution

Chopping Carrots (Hard Version) Codeforces Solution


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

The second line contains n integers a1,a2,,an (1aim) — the sequence a.

Output

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.

No comments:

Post a Comment