题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1251

map的强大之处,但是运行时间太长。

代码:

 #include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <ctype.h>
#include <iomanip>
#include <queue>
#include <map>
#include <stdlib.h>
using namespace std; map<string,int> M; int main(){
string x;
char a;
while(true){
scanf("%c",&a);
if(a=='\n'){
scanf("%c",&a);
x=""; //字符串 x 清空
}
if(a=='\n')break;
x+=a;
M[x]+=;
}
while(cin>>x)
printf("%d\n",M[x]);
return ;
}

hdu 统计难题(map)的更多相关文章

  1. hdu 1251 统计难题 (map水过)

    # include <stdio.h> # include <algorithm> # include <string> # include <map> ...

  2. HDU1251 统计难题[map的应用][Trie树]

    一.题意 给出一组单词,另给出一组单词用作查询,求解对于每个用于查询的单词,前一组中有多少个单词以其为前缀. 二.分析 根据题目很容易想到hash的方法,首先可以朴素的考虑将第一组中的所有单词的前缀利 ...

  3. hdu 1251:统计难题[【trie树】||【map】

    <题目链接> 统计难题                        Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131 ...

  4. HDU 1251 统计难题(Trie模版题)

    统计难题 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131070/65535 K (Java/Others) Total Subm ...

  5. hdu 1251 统计难题(字典树)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1251 统计难题 Time Limit: 4000/2000 MS (Java/Others)    M ...

  6. hdu 1251 统计难题 (字典树入门题)

    /******************************************************* 题目: 统计难题 (hdu 1251) 链接: http://acm.hdu.edu. ...

  7. HDU 1251 统计难题(Trie)

    统计难题 [题目链接]统计难题 [题目类型]Trie &题解: Trie的模板题,只不过这题坑点在没给数据范围,改成5e5就可以过了,用的刘汝佳蓝书模板 &代码: #include & ...

  8. HDU 1251 统计难题 (字典树)(查询是否为前缀)

    统计难题 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131070/65535 K (Java/Others)Total Submi ...

  9. HDU-1251 统计难题,字典树或者map!

    统计难题 很久就看过这个题了,但不会~~~不会~~ 题意:给出一张单词表,然后下面有若干查询,每次给出一个单词,问单词表中是否存在以这个单词为前缀的单词,输出数量.本身也是自身的前缀.只有一组数据! ...

随机推荐

  1. Android 省市县 三级联动(android-wheel的使用)

    转载请注明出处:http://blog.csdn.net/lmj623565791/article/details/23382805 今天没事跟群里面侃大山,有个哥们说道Android Wheel这个 ...

  2. 合作编辑室计费系统(一)-SVN常见错误

    联合室已完成,在不到一个月的时间,我们的团队:嗤.陈琛.我.这段时间都挺辛苦的.从心里这次合作,真的让我们学习了非常多,学会了接纳和承担. 在我们開始合作机房的时候,社和师哥就给我们做了功课,说你们好 ...

  3. CareerCup它1.8 串移包括问题

    [称号] 原文: 1.8 Assume you have a method isSubstring which checks if one word is a substring of another ...

  4. leetcode第一刷_Merge Sorted Array

    水题,只是思想还是实用的. 当然能够新建出一个数组.比較着拷贝过去.可是没有必要啊亲.想想为什么用源数组会麻烦,由于确定了前面的数.为了后面的数字不被覆盖,要依次往后移,转念一想,先确定后面的数字.就 ...

  5. 左右db_block_size了解和实验

    关于db_block_gets了解和实验 实验 一. 自己手动创建的小表 创建一个区大小为  40k  SYS@ORCL>show parameter db_block_size NAME   ...

  6. 解决IIS7中出现An error occurred on the server when processing the URL错误提示的方法

    在IIS7上配置一个asp程序,出现了一个错如提示: An error occurred on the server when processing the URL. Please contact t ...

  7. 在最完整的搜索提示降史上的用户交互的研究——阅读《An Eye-tracking Study of User Interactions with Query Auto Completion》

            搜索下拉提示(Query Auto Completion,简称QAC)如今差点儿是每一个搜索引擎必备的基本功能,作用是在用户在搜索框输入查询词的过程中,给用户展示一系列搜索查询quer ...

  8. 【SQL Server性能优化】SQL Server 2008该表压缩

    当数据库是比较大的,而当你想备份,我们可以启动数据库备份压缩.这项由于备份文件比较小的压缩,所以整个备份的更快的速度,同时还低了磁盘空间的消耗. 当然还有一方面.肯定会添加cpu的消耗.只是一般的se ...

  9. super.getClass()与this.getClass()

    原文地址:http://leihuang.org/2014/11/14/getClass-method/ 首先看一段代码: import java.util.Date; public class Te ...

  10. SenchaTouch2.3.1 正在使用listpaging以及pullrefresh插入 分页演示样品做

    实际上本实施例是相对简单的.自定义PullRefreshFn插头继承Ext.plugin.PullRefresh. 主要是其附加refreshFn下拉监控事件. listpaging么改动.再将这两个 ...