hdu 1247 map的使用
http://acm.hdu.edu.cn/showproblem.php?pid=1247
Hat’s Words
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7760 Accepted Submission(s): 2814
You are to find all the hat’s words in a dictionary.
Only one case.
////////////////////////////////////////////////////////////////////////////////////////////////////
可以用map做,但是用字典树好一点,暂时还不会,留个坑
#include <stdio.h>
#include <string.h>
#include <map>
#include <iostream>
#include <algorithm> using namespace std; int main()
{
string str[];
int tmp=;
int tot=;
map<string,int> cas;
while(cin>>str[tot++])
{
cas[str[tot-]]=;
}
for(int i=;i<tot;i++)
{
for(int j=;j<str[i].length();j++)
{
if(cas[str[i].substr(,j)]== && cas[str[i].substr(j)]==)
{
cout<<str[i]<<endl;
break;
}
}
}
return ;
}
hdu 1247 map的使用的更多相关文章
- HDU 1247 Hat's Words (map+string)
Hat’s Words Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- HDU 1247 Hat’s Words(map,STL,字符处理,string运用)
题目 用map写超便捷 也可以用字典树来写 我以前是用map的: #include<stdio.h> #include<string.h> #include<algori ...
- HDU 1247 Hat’s Words (字典树 && map)
分析:一開始是用递归做的,没做出来.于是就换了如今的数组.即,把每个输入的字符串都存入二维数组中,然后创建字典树.输入和创建完成后,開始查找. 事实上一開始就读错题目了,题目要求字符串是由其它两个输入 ...
- hdu 1075 (map)
http://acm.hdu.edu.cn/showproblem.php?pid=1075 What Are You Talking About Time Limit: 10000/5000 MS ...
- HDU 1247 - Hat’s Words - [字典树水题]
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1247 Problem DescriptionA hat’s word is a word in the ...
- HDU 1247 Hat’s Words(字典树)
http://acm.hdu.edu.cn/showproblem.php?pid=1247 题意: 给出一些单词,问哪些单词可以正好由其他的两个单词首尾相连而成. 思路: 先将所有单独插入字典树,然 ...
- hdu 4941 map的使用
http://acm.hdu.edu.cn/showproblem.php?pid=4941 给定N,M和K,表示在一个N*M的棋盘上有K个棋子,给出K个棋子的位置和值,然后是Q次操作,对应的是: 1 ...
- hdu 2112 HDU Today(map与dijkstra的结合使用)
HDU Today Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- HDU 1247 Hat’s Words(字典树变形)
题目链接:pid=1247" target="_blank">http://acm.hdu.edu.cn/showproblem.php? pid=1247 Pro ...
随机推荐
- FreeOnTerminate 的线程在线程管理类的Destroy释放时手工释放的问题
这个问题折腾了我整整一天. 有一个线程管理类,集中管理所有新建的线程, 线程统一在创建时标识 FreeOnTerminate 为 True. 因为有的线程是不限次循环的,所以在管理类最后 Destro ...
- linux设备驱动归纳总结(四):5.多处理器下的竞态和并发【转】
本文转载自:http://blog.chinaunix.net/uid-25014876-id-67673.html linux设备驱动归纳总结(四):5.多处理器下的竞态和并发 xxxxxxxxxx ...
- XP+devOps开发模式与scrum敏捷开发对比,docker虚拟化
XP+devOps开发模式与scrum敏捷开发对比,docker虚拟化 我们现在用的就是典型的XP+devOps模式,已经放弃scrum了 现在还很多公司弄docker虚拟化docker非常复杂,当然 ...
- python3.4 or 3.x xlwt replaced with xlwt-future
Q:最近在使用python3.4处理一些生物信息数据,需要将内容保存到excel中,但是,但是,发现xlwt不能再3.4中使用,即使安装也安装不成功. 由于xlwt不兼容python3.4(x),不必 ...
- UnicodeDecodeError: ‘ascii’ codec can’t decode...: ordinal not in range(128 问题解决
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe5 in position 108: ordinal not in range(128 原 ...
- weblogic的jar包冲突
异常: Error creating bean with name 'sessionFactoryWrite' defined in class path resource [applicationC ...
- PHP的数据类型、常量、时间
[数据类型之间相互转换] ◆ 一种是强制转换: setType( 变量, 类型); // 类型 int, integer, float, double,real, bool, boolena, st ...
- cat > 命令也可以创建文档
今天看<Linux/Unix系统编程手册>,发现用cat > 命令也可以直接创建文本文档: cat > testcatcreate.txttesttest [2]+ Stopp ...
- 解决php与IIs的冲突
ISS与apache 服务器的默认端口号为 :80: 在浏览时,无法访问到. 可以将 apache的端口 改变即可: Apache安装好后,在其安装目录下的conf文件夹内会有httpd.conf这样 ...
- 20145227 《Java程序设计》实验四实验报告
20145227 <Java程序设计>实验四实验报告 实验内容 安装Andriod Studio并配置软件 使用Andriod Studio软件实现Hello World的小程序 实验步骤 ...