Codeforces Round 710 (Div. 3) |
---|
Finished |
You are given a string $$$s$$$, consisting of lowercase Latin letters. While there is at least one character in the string $$$s$$$ that is repeated at least twice, you perform the following operation:
For example, if $$$s=$$$"codeforces", then you can apply the following sequence of operations:
Given a given string $$$s$$$, find the lexicographically maximum string that can be obtained after applying a certain sequence of operations after which all characters in the string become unique.
A string $$$a$$$ of length $$$n$$$ is lexicographically less than a string $$$b$$$ of length $$$m$$$, if:
For example, the string $$$a=$$$"aezakmi" is lexicographically less than the string $$$b=$$$"aezus".
The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$). Then $$$t$$$ test cases follow.
Each test case is characterized by a string $$$s$$$, consisting of lowercase Latin letters ($$$1 \le |s| \le 2 \cdot 10^5$$$).
It is guaranteed that the sum of the lengths of the strings in all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test case, output the lexicographically maximum string that can be obtained after applying a certain sequence of operations after which all characters in the string become unique.
6 codeforces aezakmi abacaba convexhull swflldjgpaxs myneeocktxpqjpz
odfrces ezakmi cba convexhul wfldjgpaxs myneocktxqjpz
Name |
---|