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 ...
随机推荐
- macaca 测试web(2)
还是以博客园登录为例, 可以查看上一篇上一篇 这次只测试登录,使用ddt的数据驱动,这里我博客也有记录 地址 其实我在uiautomator +python 实现安卓自动化 一文当中我已经使用过ddt ...
- Begin the new life as a coder
今天刚刚开通博客园的博客频道,这里将成为自我成长点滴记录的土壤!从今天开始,从这篇博文开始,我将分享自己从一个fresher开始的成长经历.原与广大仁人志士共同在程序中共享快乐!我真是太高兴了 :D
- JAVA定时任务实现的几种方式
近日项目开发中需要执行一些定时任务,比如需要在每天凌晨时候,分析一次前一天的日志信息,借此机会整理了一下定时任务的几种实现方式,由于项目采用spring框架,所以我都将结合spring框架来介绍. 一 ...
- indexOf和lastIndexOf方法
lastIndexOf 方法: 返回 String 对象中子字符串最后出现的位置. strObj.lastIndexOf(substring[startindex]) 参数:strObj必选项.Str ...
- 第4阶段——制作根文件系统之分析init进程(2)
本节目标: (1) 了解busybox(init进程和命令都放在busybox中) (2) 创建SI工程,分析busybox源码来知道init进程做了哪些事情 (3) 分析busybox中init进 ...
- docker在CentOS7下部署指南
docker只支持CentOS7.x系统,所以近期根据docker官网指南自己搭建了一套,供大家参考. 1.部署Centos7.x系统,查看系统版本. 2.执行 sudo yum update 更新到 ...
- 深入理解计算机系统(2.3)------布尔代数以及C语言运算符
本篇博客我们主要讲解计算机中的布尔代数以及C语言的几个运算符. 1.布尔代数 我们知道二进制值是计算机编码.存储和操作信息的核心,随着计算机的发展,围绕数值0和1的研究已经演化出了丰富的数学知识体系. ...
- web项目的发布
1.我们将web项目布署到IIS上之前需要将我们的源码发布,然后再将发布后的代码布署到II上 2.首先在VS上打开我们的应用程序,在WEB层上右键->发布,会弹出一个"发布web&qu ...
- 201521123083《Java程序设计》第8周学习总结
1. 本周学习总结 这周因为一些事情耽搁了,几乎没什么打java代码,这几天尽量补过来 2. 书面作业 1.List中指定元素的删除 1.1 实验总结 不贴大段代码了,简要总结一下.切割成数组,主要用 ...
- 201521123035《Java程序设计》第七周学习总结
1. 本周学习总结 以你喜欢的方式(思维导图或其他)归纳总结集合相关内容. 参考资料: XMind 2. 书面作业 1.ArrayList代码分析 1.1 解释ArrayList的contains源代 ...