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. 现学现卖】IntelliJ+EmmyLua 开发调试Unity中Xlua

    http://blog.csdn.net/u010019717/article/details/77510066?ref=myread http://blog.csdn.NET/u010019717 ...

  2. [Activator-HelloAkka] Create our Actors

    So far we have defined our Actor and its messages. Now let's create an instance of this actor. In Ak ...

  3. 理解Windows注册表

    理解Windows注册表 注意 完之前先备份reg 前言 在Windows 3.x之前, Windows都是使用.ini文件来保存配置信息的, 但是.ini文件的大小最大只能为64KB, 为了突破这个 ...

  4. MYSQL冷知识——ON DUPLICATE KEY 批量增删改

    一 有个需求要批量增删改,并且是混合的,也就是仅不存在才增. 删简单,因为有个deleteStaute之类的字段,删除本质上就是就是一个修改 所以就是实现批量混合增改,然而组长说mysql不支持混合增 ...

  5. 【Shell】shell的运算

    一.除法 a=12 b=7 1) expr $a / $b  计算出结果为个1 ,只支持整除 2) echo "scale=2;$a/$b" | bc结果为 1.71 3) awk ...

  6. nginx禁止对写操作timeout时retry

    1) nginx禁止对写操作timeout时retry 以前遇到的一个case,业务那边说一笔请求从nginx端发送给后端tomcat了2次(落在两个不同的tomcat节点上).后来发现是nginx发 ...

  7. [转]Session and application state in ASP.NET Core

    本文转自:https://docs.microsoft.com/en-us/aspnet/core/fundamentals/app-state By Rick Anderson and Steve ...

  8. Thrift笔记(五)--Thrift server源码分析

    从(四)server代码跟进 public static void simple(MultiplicationService.Processor processor) { try { TServerT ...

  9. lua继承

    lua中其实是没有类的,有的只是表(table) lua查找一个表元素时的规则,其实就是如下3个步骤: 1.在表中查找,如果找到,返回该元素,找不到则往下看: 2.判断该表是否有元表,如果没有元表,返 ...

  10. scale 和 zoom,以及zoom的一些变态用法

    zoom和scale这两个东西都是用于对元素的缩放,一下是其中一些区别: 1.scale的缩小是以图片的中心,zoom的缩小是以图片的左上角. 2.zoom的缩放改变了元素占据的空间大小:而scale ...