当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2664:Harry Potter and His Magic Scroll

题目描述
Harry Potter want to make some scrolls to improve his magic power. He has a very big incantation dictionary, and the content of a scroll, must be a continuous passage from the dictionary. To make the scroll more powerful, Harry pick out a few powerful magic words, and want the scroll contains them. Given such magic words, where to start and where to end, to make the total number of words Harry Potter must write down for a scroll minimum? If there are some passages whose length are equal, choose the one which start first.
输入解释
The first line is the number of cases.
For each case, there will be the content of the dictionary, which end with a line contains a single "#". Each line of the dictionary will not contain more than 2,000 characters, ant it will contain no more than 100,000 words. In a dictionary, Words are only splited by a single space. A word MAY in two lines.
Then followed by a line contain a integer T, indicates the number of scrolls. For each scroll, First line is an integer m meaning the number of magic words that the scroll must contain, then followed by m such magic words. The length of a word will not exceed 20.
输出解释
For each scroll, output the start dictionary character position(start from 0) and the end of it.
输入样例
1 
Harr 
y Potter want to make some scrolls to improve his magic power. 
# 
2 
2 
Harry 
Potter 
1 
to 
输出样例
0 11 
18 19 
来自杭电HDUOJ的附加信息
Recommend zty

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-2664

最后修改于 2020-10-25T22:55:40+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)