复合词 (Compund Word,UVa 10391)
题目描述:

题目思路:
用map保存所有单词赋键值1,拆分单词,用map检查是否都为1,即为复合词
#include <iostream>
#include <string>
#include <map>
using namespace std;
map<string,int> dict ;
string str[] ;
int main(int argc, char *argv[])
{
int count = ;
while(cin >> str[count]){
dict[str[count]] = ;
count ++ ;
}
for(int i = ;i < count ;i++){
for(int j = ;j < str[i].length() ;j++){
string word1,word2 ;
word1 = str[i].substr(,j) ;
word2 = str[i].substr(j) ;
if(dict[word1] && dict[word2]) {
cout << str[i] << '\n';
break;
}
}
}
return ;
}
复合词 (Compund Word,UVa 10391)的更多相关文章
- 复合词(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 ...
- UVA 10391 - Compound Words 字符串hash
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
- UVA 10391 stl
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- UVa 10391 (水题 STL) Compound Words
今天下午略感无聊啊,切点水题打发打发时间,=_=|| 把所有字符串插入到一个set中去,然后对于每个字符串S,枚举所有可能的拆分组合S = A + B,看看A和B是否都在set中,是的话说明S就是一个 ...
- 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 ...
- 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
这个题,单纯做出来有很多种方法,但是时间限制3000ms,因此被TL了不知道多少次,关键还是找对最优解决方法,代码附上: #include<bits/stdc++.h> using nam ...
- UVa第五章STL应用 习题((解题报告))具体!
例题5--9 数据库 Database UVa 1592 #include<iostream> #include<stdio.h> #include<string.h&g ...
随机推荐
- 不推荐在iOS的浏览器应用上使用click和mouseover
iOS上的Safari也支持click 和mouseover等传统的交互事件,只是不推荐在iOS的浏览器应用上使用click和mouseover,因为这两个事件是为了支持鼠标点击而设计 出来的.Cli ...
- javascript实现jsonp跨域问题+原理
在工作中往往存在跨域的问题 ,跨域是什么概念就不在这里了,搜这类问题的肯定已经知道了.下面直接探讨jsonp跨域原理 jspon跨域原理: 1.动态创建一个script标签 var script = ...
- HDU 1735 字数统计(模拟+一点点贪心的思想)
题目戳我 字数统计 Time Limit: 1000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- HDU 1028 Ignatius and the Princess III 整数的划分问题(打表或者记忆化搜索)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1028 Ignatius and the Princess III Time Limit: 2000/1 ...
- webservice 从客户端中检测到有潜在危险的 Request.Form 值
webservice中传递xml格式的参数时报错 webservice 从客户端中检测到有潜在危险的 Request.Form 值解决方案: 1.在web.config的system.web节点中添加 ...
- HTML的块状、内联、内联块状元素的特点
元素分类及特点: 1.块级元素: 在html中<div>. <p>.<h1>.<form>.<ul> 和 <li>就是块级元素. ...
- lable随堂笔记
lable标签与属性 lable标签:for属性,让标签与指定的input元素建立标签:将input元素包含在lable标签中. <table border="2" alig ...
- Deferred Lighting
Deferred lighting separate lighting from rendering and make lighting a completely image-space techni ...
- NodeJ node.js Jquery Ajax 跨域请求
Jquery + Ajax 跨域请求 说白了就是前台请求ajax数据(JSON)但是请求的数据不在本地的绝对路径下,接口数据 是没有这个安全性的我对外公开的接口数据,只要你找到接口你就可以使用里面的数 ...
- BZOJ2286: [Sdoi2011]消耗战(虚树/树形DP)
Time Limit: 20 Sec Memory Limit: 512 MBSubmit: 5246 Solved: 1978[Submit][Status][Discuss] Descript ...