【习题5-5 UVA-10391】Compound Words
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
枚举每一个串的分割点。
看看左右两个串在不在字符串中即可。
【代码】
#include <bits/stdc++.h>
using namespace std;
const int N = 12e4;
string s;
vector <string> v;
map<string, int> mmap;
int main()
{
//freopen("F:\\rush.txt", "r", stdin);
ios::sync_with_stdio(0), cin.tie(0);
while (cin >> s) v.push_back(s),mmap[s] = 1;
sort(v.begin(), v.end());
int n = v.size();
for (int i = 0; i < n; i++)
{
int len = v[i].size();
for (int j = 0; j < len-1; j++)
{
string s1 = v[i].substr(0, j + 1), s2 = v[i].substr(j + 1);
if (mmap[s1] && mmap[s2])
{
cout << v[i] << endl;
break;
}
}
}
return 0;
}
【习题5-5 UVA-10391】Compound Words的更多相关文章
- 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 ...
- UVA 10391 - Compound Words 字符串hash
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
- 复合词(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 ...
- 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(STL map)
题目 题目 分析 自认已经很简洁了,虽说牺牲了一些效率 代码 #include <bits/stdc++.h> using namespace std; set <s ...
- UVA 10391 stl
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- uva 10391
这个题,单纯做出来有很多种方法,但是时间限制3000ms,因此被TL了不知道多少次,关键还是找对最优解决方法,代码附上: #include<bits/stdc++.h> using nam ...
- 复合词 (Compund Word,UVa 10391)
题目描述: 题目思路: 用map保存所有单词赋键值1,拆分单词,用map检查是否都为1,即为复合词 #include <iostream> #include <string> ...
随机推荐
- 34.Intellij IDEA 安装lombok及使用详解
转自:https://blog.csdn.net/qinxuefly/article/details/79159018 项目中经常使用bean,entity等类,绝大部分数据类类中都需要get.set ...
- js---- localStorage的基本用法
<body> <div> <span>用户名</span> <input type="text" class='usernam ...
- 分享一段css代码学到的js知识
[].forEach.call($$('*'),function(val){ val.style.outline = '1px solid #'+(~~(Math.random()*(1<< ...
- LightOJ 1291 Real Life Traffic
Real Life Traffic Time Limit: 2000ms Memory Limit: 32768KB This problem will be judged on LightOJ. O ...
- CDN服务上线,DNSPOD布局云端生态圈
爱因斯坦曾说过,我从不去想未来,由于它来得已经够快的了.是的,随着互联网的高速发展,我们的生活节奏越来越快,可是人们的耐心却像鞋底一样越磨越薄. 遥控器按一下,鼠标点一下,仅仅要认为没意思或者等待时间 ...
- jQuery过滤选择器具体解释
基本过滤选择器 选取第一个元素(:first) //选择第一个div元素. $('#btn1').click(function(){ $('div:first').css("backgrou ...
- Mysql基本增删改查
1登陆服务器 mysql -h localhost -u username -p password 2查看存在数据库 show databases; 3创建一个数据库(例如名字为class1,以下都是 ...
- BZOJ2631: tree(LCT)
Description 一棵n个点的树,每个点的初始权值为1.对于这棵树有q个操作,每个操作为以下四种操作之一: + u v c:将u到v的路径上的点的权值都加上自然数c: - u1 v1 u2 v2 ...
- leaf cell
leaf cell是否可以理解为设计中与或非门等这些基本的单元?
- CODEVS——T1332 上白泽慧音 || 洛谷——P1726 上白泽慧音
http://codevs.cn/problem/1332/|| https://www.luogu.org/problem/show?pid=1726#sub 时间限制: 1 s 空间限制: 1 ...