编程介的小学生 2017-09-07 10:59 采纳率: 20.5%
浏览 774
已采纳

Ransom Note

Gilbert Bates, the magnate of aluminum siding, doors, and windows, has been kidnapped. You are to help the perpetrators produce a ransom note. Your raw materials are the text of a newspaper and the text of the ransom note. The ransom note is to be produced by clipping letters or strings of letters (and possibly spaces) from the newspaper and pasting them onto a blank sheet of paper to form the note. Your job is to determine the minimum number of pieces of paper that must be clipped and pasted to form the note. Between each pair of words in the note, either the clipper must contain a space or a boundary between clipping must occur (so that the blank background shows through).

Input

Standard input consists of the text of the note followed by the text of the newspaper. The text of the note is a single line, less than 20KB in length, in lowercase with no punctuation. The text of the newspaper is in upper and lower case with punctuation and newlines mixed in. Case may be ignored (aS IN aNY standard RAnsoM nOTE) and punctuation and newlines should not be clipped. The kidnappers have acquired a large number of copies of the same newspaper, so that the same or overlapping text may be clipped as many times as necessary. Every letter of the alphabet occurs at least once in the newspaper. The newspaper is smaller than 100KB in length.

Output

Print the number of clippings followed by the clippings, on per line, in the correct order to compose the note. The case of the newspaper text should be preserved. If there are several solutions, print the one with the longest first clipping, then the second, and so on. If one clipping appears several times in the newspaper, choose any one.

Sample Input

drop the price on new thermopanes now or else
Rain Users Guide
While "rain" was intended to be a general purpose tool, at the time of
writing the primary goal was to study one particular software system.
As a result, some steps that are only done once (such as extracting
information from the program under study) are done using cumbersome
ad-hoc techniques that require significant manual intervention. While
"rain" can be used on arbitrary programs, more development work needs
to be done before this is a convenient process.

Sample Output

19
d
ro
p
the pri
ce
on
ne
w
the
rm
op
an
es
n
o
W
or
el
se

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-09-23 00:56
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 vhdl+MODELSIM
  • ¥20 simulink中怎么使用solve函数?
  • ¥30 dspbuilder中使用signalcompiler时报错Error during compilation: Fitter failed,求解决办法
  • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
  • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  • ¥15 知识蒸馏实战博客问题
  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题