#P9539. Lexicographically Smallest String with Bounded Similarity
Lexicographically Smallest String with Bounded Similarity
Lexicographically Smallest String with Bounded Similarity
You are given an integer n, two integers l and r, and a lowercase letter string s of length n. The similarity between two strings a and b of length n is defined as
where \([a_i=b_i]\) is 1 if \(a_i=b_i\) and 0 otherwise.
Your task is to construct a lowercase letter string t of length n such that the similarity between t and the given string s is between l and r (inclusive). Among all such strings t, you must output the lexicographically smallest one.
Note: The letters are chosen from the set \(\{a, b, \ldots, z\}\). The lexicographical order is the usual dictionary order.
inputFormat
The first line contains three integers n, l, and r.
The second line contains a string s of length n consisting of lowercase English letters.
outputFormat
Output the lexicographically smallest string t of length n that satisfies
$$l\le \sum_{i=1}^{n}[t_i=s_i]\le r.$$
sample
2 1 1
cb
ab
</p>