本文参考自: 原文地址
We call a string, , consisting of the letters in the set a perfect stringif both the conditions below are true:
where denotes the number of occurrences of character in . For example, the diagram below demonstrates why is a perfect string:
Solve queries, where each query consists of a string,