The letters shop showcase is a string ss, consisting of n lowercase Latin letters. As the name tells, letters are sold in the shop.
字母商店的陈列是一个字符串s,包含n个小写拉丁字母,正如它的名字所说,这个店铺卖字母。
Letters are sold one by one from the leftmost to the rightmost. Any customer can only buy some prefix of letters from the string ss.
字母从最左到最右一个一个的出售,所有顾客都只能从字符串s中买一些前缀。
There are mm friends, the ii-th of them is named titi. Each of them is planning to estimate the following value: how many letters (the length of the shortest prefix) would s/he need to buy if s/he wanted to construct her/his name of bought letters. The name can be constructed if each letter is presented in the equal or greater amount.
有m个朋友,第i个人叫ti,他们中的每个人都打算去估计如下方案的价格:要买多少字母(所需最短前缀长度)他才能用这些买了的字母构造出他的名字。当且仅当库存字母大于或等于所需字母时,名字才可以被表示。
- For example, for ss="arrayhead" and titi="arya" 5 letters have to be bought ("arrayhead").
- For example, for ss="arrayhead" and titi="harry" 6 letters have to be bought ("arrayhead").
- For example, for ss="arrayhead" and titi="ray" 5 letters have to be bought ("arrayhead").
- For example, for ss="arrayhead" and titi="r" 2 letters have to be bought ("arrayhead").
- For example, for ss="arrayhead" and titi="areahydra" all 9 letters have to be bought ("arrayhead").
It is guaranteed that every friend can construct her/his name using the letters from the string ss.
题目保证这些人的名字都可以在s中找到构造方案。
Note that the values for friends are independent, friends are only estimating them but not actually buying the letters.
注意每个人的方案估值都是独立的,也就是说他们只评估但实际上不买字母