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

题意:

给出几个串,输出能有里面的串组成的串

思路:

将每个串存在集合里面,然后将每个串截成不同形式,在集合里寻找是否有这个串

#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<queue>
#include<set>
#include<map>
#include<string>
using namespace std;
typedef long long LL;
int main()
{
string str;
set<string> Set;
while(cin>>str)
{
Set.insert(str);
}
set<string>::iterator it;
for(it=Set.begin();it!=Set.end();it++)
{
string str1=*it;
int l=str1.size();
for(int i=;i<l;i++)
{
string one=str1.substr(,i+);
string two=str1.substr(i+,l-i);
if(Set.find(one)!=Set.end()&&Set.find(two)!=Set.end())
{
cout<<str1<<endl;
break;
}
}
}
return ;
}

代码:

复合词(Compound Words, UVa 10391)(stl set)的更多相关文章

  1. UVA 10391 stl

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

  2. 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 ...

  3. UVa 10391 (水题 STL) Compound Words

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

  4. UVA 10391 - Compound Words 字符串hash

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

  5. uva 10391 Compound Words <set>

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

  6. UVA 10391 Compound Words

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

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

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

  8. UVA 11997 STL 优先队列

    题目链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...

  9. UVA 11995 STL 使用

    There is a bag-like data structure, supporting two operations: 1 x Throw an element x into the bag. ...

随机推荐

  1. uwsgi服务启动、关闭、重启操作

    1.      添加uwsgi相关文件 在之前的文章跟讲到过centos中搭建nginx+uwsgi+flask运行环境,本节就基于那一次的配置进行说明. 在www中创建uwsgi文件夹,用来存放uw ...

  2. javascript遍历表

    定义表结构 1. 通过id遍历 <html> <body> <table id="tb" border="1"> <t ...

  3. IE67不兼容display:inline-block,CSS hack解决

    追加以下代码:*display:inline.*zoom:1 ;} 块元素变为内联块, IE67不兼容:内联元素变为内联块,所有浏览器都支持 发现问题:当然,变为内联块后,有一个特性就是如果元素换行, ...

  4. Problem E: 积木积水 ——————【模拟】

    Problem E: 积木积水 Description 现有一堆边长为1的已经放置好的积木,小明(对的,你没看错,的确是陪伴我们成长的那个小明)想知道当下雨天来时会有多少积水.小明又是如此地喜欢二次元 ...

  5. js控制5秒返回指定界面,或上一个界面

    js控制5秒返回指定界面,代码如下 <head> <meta http-equiv="Content-Type" content="text/html; ...

  6. mysql安装与使用

    一.Mysql官方下载地址:https://www.mysql.com/downloads/ 二.下载 Community Server,这个版本是完全免费的  https://dev.mysql.c ...

  7. 【学习笔记】Java中生成对象的5中方法

    概述:本文介绍以下java五种创建对象的方式: 1.用new语句创建对象,这是最常用的创建对象的方式. 2.使用Class类的newInstance方法 3.运用反射手段,调用java.lang.re ...

  8. java字节码速查笔记

    java字节码速查笔记  发表于 2018-01-27 |  阅读次数: 0 |  字数统计: |  阅读时长 ≍ 执行原理 java文件到通过编译器编译成java字节码文件(也就是.class文件) ...

  9. SVN服务器在Ubuntu16.04下搭建多版本库详细教程

    1  介绍  Subversion是一个自由,开源的版本控制系统,这个版本库就像一个普通的文件服务器,不同的是,它可以记录每一次文件和目录的修改情况.这样就可 以很方面恢复到以前的版本,并可以查看数据 ...

  10. SQL Server 与 ADO.NET 数据类型映射

    SQL Server 数据类型映射 .NET Framework 4.5 SQL Server 和 .NET Framework 基于不同的类型系统. 例如,.NET Framework Decima ...