UVa 10391 Compound Words (compound word)

Source: Internet
Author: User

Test instructions outputs all words in the input word that can be made up of another two words

Application of STL set enumerate all possible splits for each word and see if all two of the broken words exist, you can output the

#include <bits/stdc++.h>using namespace std;string A, b;set<string> s;set<string>::iterator i;int Main () {    int l;    while (Cin >> a) S.insert (a);    for (i = S.begin (); I! = S.end (); ++i)    {        L = i->length ()        ; for (int j = 1; j < l-1; ++j)        {            a = i->substr (0, J);            b = I->substr (j);            if (S.count (a) && S.count (b))            {                cout << (*i) << Endl;                Break    ;    }}} return 0;}

Compound Words

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

Input

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

Output

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

Sample Input
Aalienbornlesslienneverneverthelessnewnewbornthezebra

Sample Output
Aliennewborn


UVa 10391 Compound Words (compound word)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.