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 ...
随机推荐
- notification 通知
1. 定义一个方法 -(void) update{ } 2. 对象注册,并关连消息 [[NSNotificationCenter defaultCenter]addObserver:self sele ...
- 【转】Delphi利用系统环境变量获取常用系统目录
Delphi code //譬如 %WINDIR% 是表示系统目录的系统变量, 可以这样获取: var s: string; begin s := GetEnvironmentVariable('WI ...
- 161020、web调试工具fiddler介绍及使用
简介: Fiddler是一个http协议调试代理工具,它能够记录并检查所有你的电脑和互联网之间的http通讯,设置断点,查看所有的"进出"Fiddler的数据(指cookie,ht ...
- 兼容IE, Chrome的ajax function
gAjax.js var gAjax = (function () { /* paramObj:{ url: request url, method: GET or POST, encode: cha ...
- (转载)PERL 处理CSV
#!/usr/bin/perl#use strict;open(FILE1,"C:/Perl/BX/BX-Users.csv");open(FILE2,"C:/Perl/ ...
- js 闭包理解
闭包主要应用于两种情况: 1 函数作为返回值. 2 函数作为参数传递. 第一种举例: function fn(){ var max = 10; return function bar(){ if(x ...
- windows tomcat配置大全
Tomcat下JSP.Servlet和JavaBean环境的配置 第一步:下载j2sdk和tomcat:到sun官方站点()下载j2sdk,注意下载版本为Windows Offline Install ...
- Buy Tickets
Buy Tickets Time Limit: 4000MS Memory Limit: 65536K Total Submissions: 16010 Accepted: 7983 Descript ...
- U3D刚体测试1-刚体非刚体物体非Kinematic等之间的碰撞关系
Unity官方有一个详细的碰撞关系表:http://docs.unity3d.com/Manual/CollidersOverview.html 但其实可以精简为以下几点: 1.两个勾选kinemat ...
- nginx配置SSL证书(使用startSSL申请到的免费证书)
1. 在startSSL注册申请免费证书,此处不赘述,参考 http://www.freehao123.com/startssl-ssl/ 申请过程中会生成Private Key,将Private K ...