ZOJ 1825 Compound Words

Source: Internet
Author: User

Compound wordstime limit:5000msmemory limit:32768kbthis problem would be judged onZju. Original id:1825
64-bit integer IO format: %lld Java class name: Main 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

A
Alien
Born
Less
Lien
Never
Nevertheless
New
Newborn
The
Zebra


Sample Output

Alien
Newborn

SourceUniversity of Waterloo Local Contest 1996.09.28 problem Solving: Long time no code to start a brain residue
1#include <bits/stdc++.h>2 using namespacestd;3unordered_set<string>us;4 stringword[1000010];5 intMain () {6Ios::sync_with_stdio (false);7     inttot =0;8      while(Cin>>word[tot]) Us.insert (word[tot++]);9      for(inti =0; i < tot; ++i) {Ten         if(Word[i].length () >1) { One              for(intj =1, Len = Word[i].length (); J < Len; ++j) { A                 stringA = Word[i].substr (0, j); -                 stringb =Word[i].substr (j); -                 if(Us.count (a) &&Us.count (b)) { thecout<<word[i]<<Endl; -                      Break; -                 } -             } +         } -     } +     return 0; A}
View Code

ZOJ 1825 Compound Words

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.