The meaning of problems: you sample groups, give you two characters a, b, len a length, a length len of the string str, str is a substring of string s
str is deleted except through s a, b two remaining substring of characters, and now seek s, one kind of the output more. Out output configuration -1
Ideas:
I can imagine topological sorting .
Because this is certainly str substring S satisfies the order relationship s, str so built FIG sequentially, and because it gives all built several substrings FIG, if the last topology finish, resulting string length is equal to the length s .
So in the future seek the order encountered some problems or map, even if it is against the strings to the topological sorting
Details: For this question the most important thing is for each character number
pos = (s [i] - 'a') * 10000 + sum; the number of occurrences of that character SUM;
ANS + = (. 1-U) / 10000 + 'A'; U is a number; CC this situation occurs instantly, No. 20001,20002, the (u-1) / 10000 + 'a result is equal to c a
strong batch numbering