2013
12-21

# Power Word

Recently, loneknight is interesting in investigating the power of word. After several weeks of research, He recognize that there are some magic words in the world, if a word contains a magic word as its substring, it will have magic power. For example, if the word ‘magic’ is magic word, then the word ‘magic’, ‘amagic’, ‘xxmagic’, ‘magiczz’ are all power words.

In addition to this finding, he also find that the index of a powerword has a important impact on the power of word. The index of a power word define as follow: given the set of magic words, if we list all the powerword contain one or more magic word as substring in a list lexicographically from short length to long, the curring position of a word in the list is its index. So, if the magic words are ‘magic’ and ‘hello’, then word have index 1 is ‘hello’, the word have index 2 is ‘magic’, the word have index 3 is ‘ahello’ … (only consider the lowercase words) .

Now, loneknight have find a way to calculate the the indices of the most powerful words, he want to find what the actually word is. Can you help him?

The input consists of several test cases. Each case contain exactly two line, first line contains the magic words, words are seperated by spaces, the length of each word is at least 1 and at most 5, and the word contain only lowercase characters, the second line contains the indices, indices are seperated by spaces each index in the range [1, 232-1]. (Each line contains at most 10 words or numbers) Your job is to find the powerful word according the indices. The input end with a ling contain "-1".

For each case, please print the powerful words in a single line seperated by one space without trailing space, according to the order in the input.

hello magic
1 2 3
hello magic
4294967295
hello magic
67 141
-1

hello magic ahello
yskwojhello
magico ahellou

1. 我一直觉得，蚂蚁蜜蜂这种东西，一个群体才能叫一个生命体。蚁后是该生命的生殖系统和自我修复系统，工蚁是运动系统，信息素是神经系统。而且这个生命体自我修复能力特别强，哪怕损失了所有的运动系统，只要生殖系统还在，就能自我修复到一个完整的生命。

2. Gucci New Fall Arrivals

This is really nice to know. I hope it will be successful in the future. Good job on this and keep up the good work.

3. 嗯 分析得很到位，确实用模板编程能让面试官对你的印象更好。在设置辅助栈的时候可以这样：push时，比较要push的elem和辅助栈的栈顶，elem<=min.top()，则min.push(elem).否则只要push（elem）就好。在pop的时候，比较stack.top()与min.top(),if(stack.top()<=min.top()),则{stack.pop();min.pop();}，否则{stack.pop();}.

4. 第23行：
hash = -1是否应该改成hash[s ] = -1

因为是要把从字符串s的start位到当前位在hash中重置

修改提交后能accept，但是不修改居然也能accept