#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <deque>
#include <set>
typedef long long ll;
#define lowbit(x) (x&(-x))
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
using namespace std;
const int N=1e6+;
int tree[N][];//26个字母
int num[N];
char s[];
int pos;
void insert(char s[]){
int root=,i;
for(i=;s[i];i++){
int x=s[i]-'a';
if(!tree[root][x]){
tree[root][x]=pos++;
}
root=tree[root][x];
num[root]++;
}
}
int query(char s[]){
int i;
int root=;
for(i=;s[i];i++){
int x=s[i]-'a';
if(!tree[root][x]){
return ;
}
root=tree[root][x];
}
return num[root];
}
int main()
{
pos=;
/*
memset(tree,0,sizeof(tree));
memset(num,0,sizeof(num));
*/
//加上上面的会超内存
while(gets(s)){//不要用scanf
if(s[]==NULL)
break;
insert(s);
}
while(gets(s)){
printf("%d\n",query(s));
}
return ;
}

huu 1251的更多相关文章

  1. BZOJ 1251: 序列终结者 [splay]

    1251: 序列终结者 Time Limit: 20 Sec  Memory Limit: 162 MBSubmit: 3778  Solved: 1583[Submit][Status][Discu ...

  2. poj 1251 Jungle Roads (最小生成树)

    poj   1251  Jungle Roads  (最小生成树) Link: http://poj.org/problem?id=1251 Jungle Roads Time Limit: 1000 ...

  3. hduoj 1251 统计难题

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

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

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

  5. BZOJ 1251: 序列终结者

    1251: 序列终结者 Time Limit: 20 Sec  Memory Limit: 162 MB Submit: 3773  Solved: 1579 [Submit][Status][Dis ...

  6. ural 1251. Cemetery Manager

    1251. Cemetery Manager Time limit: 1.0 secondMemory limit: 64 MB There is a tradition at the USU cha ...

  7. HDU 1251 Trie树模板题

    1.HDU 1251 统计难题  Trie树模板题,或者map 2.总结:用C++过了,G++就爆内存.. 题意:查找给定前缀的单词数量. #include<iostream> #incl ...

  8. Poj(1251),Prim字符的最小生成树

    题目链接:http://poj.org/problem?id=1251 字符用%s好了,方便一点. #include <stdio.h> #include <string.h> ...

  9. njoj 1251 zlly长了一张包子脸

    njoj 1251 zlly长了一张包子脸 题意: zlly长了一张包子脸.他特别喜欢吃糖果.如今他手头有若干种糖果,每种糖果有个口味值,每种糖果有无数多个.然后娄童鞋也很喜欢吃糖果.他的口味特别广泛 ...

随机推荐

  1. 076 Minimum Window Substring 最小窗口子字符串

    给定一个字符串 S 和一个字符串 T,找到 S 中的最小窗口,它将包含复杂度为 O(n) 的 T 中的所有字符.示例:S = "ADOBECODEBANC"T = "AB ...

  2. Golang 入门系列(十三)用Beego开发web应用

    接着之前的内容,前面已经讲过很多Golang的基础语法,mysql的使用,redis的使用,也讲了orm框架,如何创建一个webapi 服务等等,感兴趣的可以看看以前的文章,https://www.c ...

  3. 用canvas裁剪图片

    var selectObj = null; function ImageCrop(canvasId, imageSource, x, y, width, height) { var canvas = ...

  4. 【转】LINQ to SQL语句(1)之Where

    Where操作 适用场景:实现过滤,查询等功能. 说明:与SQL命令中的Where作用相似,都是起到范围限定也就是过滤作用的,而判断条件就是它后面所接的子句. Where操作包括3种形式,分别为简单形 ...

  5. IOS使用固定定位遇到的问题

    近日需要实现移动端页面额外功能按钮,即点击加号弹出点赞与留言功能,通常这个按钮都会固定于页面的右下角,首先就想到使用固定定位来实现. 但是在测试时我们发现,在IOS中,当系统键盘弹出时,fixed会失 ...

  6. Typedef 用法

    typedef声明有助于创建平台无关类型,甚至能隐藏复杂和难以理解的语法. 不管怎样,使用 typedef 能为代码带来意想不到的好处,通过本文你可以学习用typedef避免缺欠,从而使代码更健壮.  ...

  7. SpringBoot:异步开发之异步调用

    前言 除了异步请求,一般上我们用的比较多的应该是异步调用.通常在开发过程中,会遇到一个方法是和实际业务无关的,没有紧密性的.比如记录日志信息等业务.这个时候正常就是启一个新线程去做一些业务处理,让主线 ...

  8. ios 设置cell的间距

    1.设置假的间距,我们在tableviewcell的contentView上添加一个view,比如让其距离上下左右的距离都是10:这个方法是最容易想到的: 2.用UIContentView来代替tab ...

  9. Python3自动化学习地址

    w3社区https://www.w3cschool.cn/python/ 易百教程https://www.yiibai.com/ http://www.cnblogs.com/yangxia-test ...

  10. github的pull Request使用

    场景: teamA要一起做一个项目,选择用github管理自己的代码仓库,这时userA在github上新建了一个远程仓库,其他人需要通过pull request来实现提交.那么,问题来了,pull ...