复合词 (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 ...
随机推荐
- java线程安全单例
public class MySingleton { // 使用volatile关键字保其可见性 volatile private static MySingleton instance = null ...
- Classless Interdomain Routing (CIDR)
IP Address Problems IP Address Exhaustion Class A, B, and C address structure inefficient Class B to ...
- Dokcer-ce安装脚本
安装docker #!/bin/bash # coding: utf- # Copyright (c) set -e #返回值为0时,退出脚本 echo "1. 备份yum" { ...
- 自动化运维工具Ansible实战(四)常用模块
转载链接:http://blog.51cto.com/liqingbiao/1962609 Ansible模块按功能分为:云模块.集群模块. 命令模块.数据库模块.文件模块.资产模块.消息模块.监 ...
- WebPack系列之Proxy
背景 当我们直接去访问https://m.weibo.cn/api/config/list时由于端口.域名的不同产生了跨域,无法请求到资源数据. 分析 WebPack中devServer的proxy代 ...
- MySQL语句整理(二)
数据库操作前的准备 -- 创建数据库 -- create database python_test_1 charset=utf8; -- 使用数据库 -- use python_test_1; -- ...
- Java 序列化与反序列化(Serialization)
一.什么是?为什么需要? 序列化(Serialization)是将对象的状态信息转化为可以存储或者传输的形式的过程,反序列化则为其逆过程. 内存的易失性:传输需要:一些应用场景中需要将对象持久化下来, ...
- Java实现“睡排序”——线程池Executors的使用
前提 之前在知乎上看见一个有意思的排序算法——睡排序. 睡排序最早好像是4chan上一个用户用shell脚本实现的: 算法思想简洁明了:利用进程的sleep来实现 越大的数字越迟输出. 虽然像2L说的 ...
- angularjs脏机制
Angular 每一个绑定到UI的数据,就会有一个 $watch 对象. watch = { name:'', //当前的watch 对象 观测的数据名 getNewValue:function($s ...
- react基本demo详解
一.react的优势 1.React速度很快:它并不直接对DOM进行操作,引入了一个叫做虚拟DOM的概念,安插在javascript逻辑和实际的DOM之间,性能好. 2.跨浏览器兼容:虚拟DOM帮助我 ...