P20375 [CodeChef] JOJOA
普及
题目描述

Dio Brando has set a goal for himself of becoming the richest and the most powerful being on earth.To achieve his goals he will do anything using either manipulation,seduction or plain violence.
Only one guy stands between his goal of conquering earth ,named Jotaro Kujo aka JoJo .Now Dio has a stand (visual manifestation of life energy i.e, special power ) “Za Warudo” ,which can stop time itself but needs to chant few words to activate the time stopping ability of the stand.There is a code hidden inside the words and if you can decipher the code then Dio loses his power.
In order to stop Dio ,Jotaro asks your help to decipher the code since he can’t do so while fighting Dio at the same time.
You will be given a string as input and you have to find the shortest substring which contains all the characters of itself and then make a number based on the alphabetical ordering of the characters.
For example : “bbbacdaddb”
shortest substring will be “bacd” and based on the alphabetical ordering
the answer is 2134

-----NOTE:-----
A substring is a contiguous subsegment of a string. For example, "acab" is a substring of "abacaba" (it starts in position 3 and ends in position 6), but "aa" or "d" aren't substrings of this string. So the substring of the string s from position l to position r is

S[l;r]=SlSl+1…Sr.

-----Input :-----
The first line contains $T$,number of test cases.
The second line contains a string $S$.

-----Output:-----
For each test cases ,output the number you can get from the shortest string

-----Constraints:-----
$1 \leq t \leq 100$
$1 \leq |S| \leq 10^6$

-----Test Cases:-----

-----Sample Input:-----
6

abcdfgh

urdrdrav

jojojojoj

bbbbaaa

cddfsccs

tttttttttttt

-----Sample Output:-----
1234678

2118418418122

1015

21

46193

20

-----Explanation:-----
Test case 1: abcdfgh is the shortest substring containing all char of itself and the number is 1234678

输入格式

见题面

输出格式

见题面

样例输入
['6', 'abcdfgh', 'urdrdrav', 'jojojojoj', 'bbbbaaa', 'cddfsccs', 'tttttttttttt']
样例输出
['1234678', '2118418418122', '1015', '21', '46193', '20']