UVA - 10391 Compound Words 迭代器和set
来源:互联网 发布:windows update卡在35 编辑:程序博客网 时间:2024/06/16 14:57
题目大意:给出一系列的字符串,问是否有满足 str == str1+str2的字符串,如果的有话就输出
解题思路:单词最多有120000,如果一个个加,再去比较的话,就会TLE,另一种方法,每次选择一个串,然后将串分成两部分,看这两部分是都都有,如果都有的话,就表示存在str = str1 + str2,substr(int begin,int length)
#include<cstdio>#include<cstring>#include<set>#include<iostream>using namespace std;string str[120005];int main() {int count = 0;set<string> s;while(getline(cin,str[count])) {s.insert(str[count]);count++;}for( set<string>::const_iterator it = s.begin(); it != s.end(); it++)for(int i = 0,len =it->length() ; i < len; i++)if(s.find(it->substr(0,i)) != s.end() && s.find(it->substr(i,len)) != s.end()) {cout << *it << endl;break;}return 0;}
0 0
- UVA - 10391 Compound Words 迭代器和set
- UVA 10391Compound Words 用set实现
- uva 10391 compound words
- UVa 10391 - Compound Words
- uva 10391 - Compound Words
- uva 10391 - Compound Words
- UVa 10391 - Compound Words
- UVa 10391 - Compound Words
- uva 10391 - Compound Words
- UVA 10391 Compound Words
- UVA 10391 - Compound Words
- Uva-10391-Compound Words
- UVa 10391 - Compound Words
- uva--10391 - Compound Words
- UVA 10391 Compound Words
- UVa:10391 Compound Words
- uva 10391 Compound Words
- UVa 10391 - Compound Words
- Unity3D学习笔记——layer
- C++ 硬件信息 获取网卡MAC地址
- 【AppCan 开发者】 生活中的坚持与改变
- C语言中的数组
- 0-1背包hdu1864
- UVA - 10391 Compound Words 迭代器和set
- 大数据最最根本的属性有三个——海量、开放、连接
- iOS 性能优化之懒加载
- Java匿名内部类
- Atitit. 软件GUI按钮与仪表盘--web服务器区--获取apache配置文件路径 linux and apache的启动、停止、重启
- BroadcastReceiver(广播接收器)
- poj1450
- Java Swing Ribbon(Flamingo)的使用03:按钮样式
- ORACLE中常见SET指令