uva 10391
这个题,单纯做出来有很多种方法,但是时间限制3000ms,因此被TL了不知道多少次,关键还是找对最优解决方法,代码附上;
#include<bits/stdc++.h>
using namespace std;
map<string,int>MAP;
char s[][]; int main(){
MAP.clear();
int n = ;
while(cin>>s[n]){ MAP[s[n]]=;
n++;
}
for(int i=;i<n;i++){
int l=strlen(s[i]); for(int j= ;j<l;j++){
char temp1[] = {'\0'};
char temp2[] = {'\0'};
strncpy(temp1,s[i],j);
strncpy(temp2,s[i]+j,l-j);
if(MAP[temp1]&&MAP[temp2])
{cout<<s[i]<<endl;
break;}
} }
return ; }
uva 10391的更多相关文章
- UVA 10391 stl
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- UVA 10391 - Compound Words 字符串hash
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
- 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 ...
- 复合词 (Compund Word,UVa 10391)
题目描述: 题目思路: 用map保存所有单词赋键值1,拆分单词,用map检查是否都为1,即为复合词 #include <iostream> #include <string> ...
- 复合词(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第五章STL应用 习题((解题报告))具体!
例题5--9 数据库 Database UVa 1592 #include<iostream> #include<stdio.h> #include<string.h&g ...
随机推荐
- fzu1969 GCD Extreme 类似于uva10561
Description Given the value of N, you will have to find the value of G. The meaning of G is given in ...
- [2014-08-18]初尝 AspNet vNext On Mac
网上关于AspNet vNext的介绍已经非常多,本文不再赘述,仅记录下Mac环境的几点注意事项. 环境 OSX 10.9.4 Mono 3.6.1 Kvm 1.0.0-alpha4-10285 mo ...
- linux下tomcat作为daemon进程运行
在linux下如果想让tomcat在开机时自启动,可以将启动代码写到/etc/rc.local里面.但是,这样的话,tomcat将以root权限运行,这是不安全的.因此,要想办法让tomcat以非特权 ...
- 关于wamp服务器文件的配置
有的前端朋友想在手机端看PC端开发的html5页面,这时候会在本地PC下载一个wamp,这时候在PC端输入电脑的IP地址或者是直接输入localhost,可以访问www目录下的文件(开发项目必须放置在 ...
- CSS3学习手记
--------------------CSS3新增选择器--------------------#E:nth-child(n):匹配元素类型为E且是父元素的第n个子元素#E:nth-last-chi ...
- jmeter-fileupload操作使用说明
前言:在http请求过程中上传附件(图片.安装包.视频文件等)虽然基本上Content-Type为:multipart/form-data,但Content-Type也有不一样的,如:图片Conten ...
- DOS命令运行java文件,批量引用jar包
进入class文件目录 cd:\workspace\workspace_goodsownersystem\workspace_goodsownersystem\goodsownersystem\tar ...
- 大型网站的 HTTPS 实践(四)——协议层以外的实践
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt390 1 前言 网上介绍 https 的文章并不多,更鲜有分享在大型互联网站 ...
- Linux-tar命令(2)
tar 用于可以为文件和目录创建档案.可以为某一特定文件打包(备份文件), 也可以在档案中改变文件,或者向档案中加入新的文件. 主选参数: 主选参数仅能存在一个!不可同时存在!因为不可能同时压缩与解压 ...
- Android学习记录:获取联系人
在AndroidManifest中申请读取联系人的权限 <uses-permission android:name = "android.permission.READ_CONTACT ...