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 theconcatenation 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, inalphabetical order.

Sample Input

a
alien
born
less
lien
never
nevertheless
new
newborn
the
zebra

Sample Output

alien
newborn 用set做
#include <iostream>
#include <set>
#include <string>
using namespace std; set<string>dic;
set<string>::iterator t; int main()
{
string word;
while(cin >> word)dic.insert(word); for(t = dic.begin(); t != dic.end(); t++){
word = *t;
int n = word.length(); for(int i = ; i < n - ; i++ ){
string s1=word.substr(,i+),s2 = word.substr(i+,n-i-);
if( (dic.count(s1)) && (dic.count(s2)) ){
cout << word <<endl;
break;
}
}
}
//system("pause");
return ;
}

dic.count(s2)  在set dic中计算s2的个数,并返回其个数。

uva 10391 Compound Words <set>的更多相关文章

  1. UVA 10391 Compound Words

    Problem E: Compound Words You are to find all the two-word compound words in a dictionary. A two-wor ...

  2. UVA 10391 - Compound Words 字符串hash

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  3. 复合词(Compound Words, UVa 10391)(stl set)

    You are to find all the two-word compound words in a dictionary. A two-word compound word is a word i ...

  4. Compound Words UVA - 10391

      You are to find all the two-word compound words in a dictionary. A two-word compound word is a wor ...

  5. UVa 10391 (水题 STL) Compound Words

    今天下午略感无聊啊,切点水题打发打发时间,=_=|| 把所有字符串插入到一个set中去,然后对于每个字符串S,枚举所有可能的拆分组合S = A + B,看看A和B是否都在set中,是的话说明S就是一个 ...

  6. 【UVA】10391 Compound Words(STL map)

    题目 题目     分析 自认已经很简洁了,虽说牺牲了一些效率     代码 #include <bits/stdc++.h> using namespace std; set <s ...

  7. UVA 10391 stl

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  8. uva 10391

    这个题,单纯做出来有很多种方法,但是时间限制3000ms,因此被TL了不知道多少次,关键还是找对最优解决方法,代码附上: #include<bits/stdc++.h> using nam ...

  9. 复合词 (Compund Word,UVa 10391)

    题目描述: 题目思路: 用map保存所有单词赋键值1,拆分单词,用map检查是否都为1,即为复合词 #include <iostream> #include <string> ...

随机推荐

  1. poj3258 二分 最小值最大化问题

    River Hopscotch Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 10842   Accepted: 4654 ...

  2. 【android】java.net.ConnectException: localhost/127.0.0.1:8080 - Connection refused

    调试中通过android simulator模拟器链接localhost或者127.0.0.1,因为我在电脑上面建立了apache,我的代码大概就是URL url = new URL(urlStrin ...

  3. debug模式启动provider

    debug 模式启动 1 sts中的配置见图片 2 centos中 ./knowledge-start.sh debug win系统ip ./knowledge-start.sh debug 192. ...

  4. 【笔记】shell下的主要工具

    shell 下有很多工具是非常好的辅助. 一.自我精进的途径 1.help / --help :简要的帮助说明: help 是针对 shell 内建功能的帮助, gnu工具一般为 "程序名 ...

  5. 【iOS开发】添加子控件方式(懒加载,GCC)

    // // ViewController.m // GCC // // Created by admin on 15/10/7. // Copyright © 2015年 admin. All rig ...

  6. 配置wamp环境使得在命令行下也能执行socket扩展

    首先在apache中开启socket扩展 php环境安装目录\bin\apache\apache2.2.17\bin\php.ini 去掉前面的';'   extension=php_sockets. ...

  7. Android的移动存储之SharedPreferences

    在Android系统中提供了多种存储技术.通过这些存储技术可以将数据存储在各种存储介质上.比如sharedpreferences可以将数据保存着应用软件的私有存储区,这些存储区的数据只能被写入这些数据 ...

  8. Mac OS X Mavericks使用手册

    基本信息 作者: 施威铭研究室 出版社:清华大学出版社 ISBN:9787302386018 上架时间:2014-12-30 出版日期:2015 年1月 开本:16 版次:1-1 所属分类: 计算机 ...

  9. ASP.NET MVC3 系列教程 – 新的Layout布局系统

    原文地址:http://www.cnblogs.com/highend/archive/2011/04/18/asp_net_mvc3_layout.html I:回忆MVC2当中MasterPage ...

  10. Merlin 的魔力: SpringLayout 管理器

    摘自http://tech.it168.com/a2009/0211/265/000000265087_all.shtml 摘自http://cache.baiducontent.com/c?m=9f ...