复合词(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 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)的更多相关文章
- UVA 10391 stl
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- 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 ...
- UVa 10391 (水题 STL) Compound Words
今天下午略感无聊啊,切点水题打发打发时间,=_=|| 把所有字符串插入到一个set中去,然后对于每个字符串S,枚举所有可能的拆分组合S = A + B,看看A和B是否都在set中,是的话说明S就是一个 ...
- UVA 10391 - Compound Words 字符串hash
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
- uva 10391 Compound Words <set>
Compound Words You are to find all the two-word compound words in a dictionary. A two-word compound ...
- UVA 10391 Compound Words
Problem E: Compound Words You are to find all the two-word compound words in a dictionary. A two-wor ...
- 复合词 (Compund Word,UVa 10391)
题目描述: 题目思路: 用map保存所有单词赋键值1,拆分单词,用map检查是否都为1,即为复合词 #include <iostream> #include <string> ...
- UVA 11997 STL 优先队列
题目链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...
- UVA 11995 STL 使用
There is a bag-like data structure, supporting two operations: 1 x Throw an element x into the bag. ...
随机推荐
- 最好用的数据存储Easy Save2讲解
转载:http://www.manew.com/thread-100109-1-1.html 今天抽时间学习了“Easy Save2”插件,版本v2.6.3 我个人觉得这个插件是做数据存取最好的 ...
- Appium Android sdk自动化工具安装
RF环境搭建 略 Android环境搭建 jdk1.8 配环境变量 JAVA_HOME CALSSPATH:%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar; PAT ...
- CentOS 下 安装 nginx
1.准备 安装 nginx 之前,需要确认是否安装了 GCC,PCRE, zlib, OpenSSL 等. 如未安装,则先安装这些插件 # yum install -y gcc # yum insta ...
- C# 定制特性
一.初识特性 特性(attribute)是被指定给某一声明的一则附加的声明性信息. 设计类型的时候可以使用各种成员来描述该类型的信息,但有时候我们可能不太愿意将一些附加信息放到类的内部,因为这样,可能 ...
- C#动态方法调用 提高程序的扩展性
此篇将介绍C#如何在运行时动态调用方法.当某些类型是运行时动态确定时,编译时的静态编码是无法解决这些动态对象或类的方法调用的.此篇则给你一把利剑,让动态对象的方法调用成为可能. 1.动态调用dll里的 ...
- node.js之forEach
forEach用法: var array1=[1,2,3]; array1.forEach(function(item,index){ console.log(item+'---'+index); } ...
- 07.使用FileStream类来实现对大文件的复制
namespace _20.使用FileStream类来实现多媒体文件的复制 { class Program { static void Main(string[] args) { //需要被复制的文 ...
- scss-@media
首先回顾下css3中的@media 定义和使用: 使用 @media 查询,你可以针对不同的媒体类型定义不同的样式. @media 可以针对不同的屏幕尺寸设置不同的样式,特别是如果你需要设置设计响应式 ...
- js添加、修改、删除xml节点例子
version="1.0" encoding="gb2312"?> . <bookstore> . <book genre=" ...
- ArcEngine开发鹰眼实现问题
在网上百度一下有关AE鹰眼实现的代码,基本是一样的,可问题是好多代码自己运行起来鹰眼却总是加不进地图.住视图axMapControl1.OnMapReplaced(),axMapControl1.On ...