2 shunfurh shunfurh 于 2017.09.03 23:17 提问

Compound Words

You are to find all the two-word compound words in a dictionary. A two-word compound word is a word in the dictionary that is the concatenation of exactly two other words in the dictionary.

Input

Standard input consists of a number of lowercase words, one per line, in alphabetical order. There will be no more than 120,000 words.

Output

Your output should contain all the compound words, one per line, in alphabetical order.

Sample Input

a
alien
born
less
lien
never
nevertheless
new
newborn
the
zebra

Sample Output

alien
newborn

1个回答

caozhy
caozhy   Ds   Rxr 2017.09.18 04:26
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
UVA - 10391 Compound Words(hash)
Problem E: Compound Words You are to find all the two-word compound words in a dictionary. A two-word compound word is a word in the dictionary that is the concatenation of exactly two other words
复合词(Compound Words, UVa 10391)
原题是给出一个词典,找出所有的复合词,即恰好有两个单词连接而成的单词,按照字典序输出。使用的用法是set和substr这两个办法。#include #include #include #include using namespace std; const int maxs = 100; set voca; set outvoca; string sts[maxs]; void main() {
UVa 10391 - Compound Words
题目链接: UVa: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1332 zoj :  http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=825
Compound Words(复合词) UVA 10391
解题思路:这道题开始考虑通过合成单词来做,结果超时(复杂度n*n);后面考虑通过分解单词来做(复杂度n*m(m表示单词平均长度))AC了,需要用到string中的分解函数substr(可以在STL中查询) #include#include#include#includeusing namespace std;vectorvec;            //通过下标遍历输入的单词s
习题5-5 复合词 UVa10391
1.题目描述:点击打开链接
UVa 10391 Compound Words(复合词)
题意  输出所有输入单词中可以由另两个单词的组成的词 STL set的应用  枚举每个单词的所有可能拆分情况  看拆开的两个单词是否都存在  都存在的就可以输出了 #include using namespace std; string a, b; set s; set::iterator i; int main() { int l; while(cin >> a) s.i
5-5 UVA 10391 Compound Words复合词
题目大意就不说了,紫书和原文都讲的很易懂。 本来注意到的数据范围,但依然超时了。。。 整体思路呢: 建立一个26 + 5个数组的set,根据输入单词的首字母存取输入的单词,然后在遍历每一个单词,在循环遍历单词的长度(分割单词),然后再根据分割出的两个单词在set中搜索,搜索直接在相应的首字母的set二分寻找,这样会大大减少时间(其实不分也能过!只是在害怕超时!) #include #inc
uva 10391 compound words
题目地址:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1332题目描述:You are to find all the two-word compound words in a dictionary. A two-word compound word is
Compound Words
B - Compound Words Crawling in process... Crawling failed Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Description Problem E: Compound Words
uva 10391 Compound Words
简单的set应用,简单题目 #include #include #include #include using namespace std; set dict; int main(void) { int i; bool f; char buffer[100]; string s, s1, s2; set::iterator it; //freopen("input.