URAL 1684. Jack’s Last Word

1. 题目


1684. Jack’s Last Word

Time limit: 0.5 second
Memory limit: 64 MB
Not long ago Jack read on a fence a word that was new and amusing for him. Jack liked it so much that he wanted to invent another amusing word, but no matter how hard he tried he couldn’t do it. All the words he could invent consisted of prefixes of the initial word and therefore didn’t please Jack. He continued to invent words that were longer and longer, but none of them was pleasing.
And now the time has come for Jack to have his last word.


The first line contains the amusing word that was written on the fence. The second line contains Jack’s last word. The words are nonempty, consist of lower-case English letters, and are no longer than 75000 symbols.


If Jack didn’t invent a new amusing word, output “No” in the first line. In this case, show Jack how to decompose his last word into several parts each of which is either the initial word or its nonempty prefix. Output these parts in the second line separating them with a space. If there is no such decomposition, output “Yes” in the only output line.


input output
Problem Author: Dmitry Ivankov
Problem Source: USU Open Personal Contest 2009 (February 28, 2009)

2. 思路

给出两个字符串S1和S2,求S2是否完全由S1的前缀构成。如第一个测试例,S1 = abracadabra, S2 = abrabracada,S2可以拆分成“abr”、“abracad”和“a”三个子串,这三个字


3. 代码