#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. Spring连接数据库

    public class Book { private int bookid; private String bookname; private String bookauthor; private ...

  2. sqlserver跟据当天年月日日期查询数据库当天数据

    select * from Client where  CONVERT(varchar(100), Cli_Datetime, 23) ='2017-11-06' 在查询之前要对表中datetime类 ...

  3. [20190620]日常学习记录(三)-初识promise及vuex

    在学习promise之前重温了Ajax的原生js实现, 在原生js中发送一个http请求首先new XMLHttpRequest() 然后定义状态变更事件 浏览器监听请求的状态,触发不同状态下相应的代 ...

  4. [Oracle 视图] ALL_OBJECTS

    ALL_OBJECTS ALL_OBJECTS describes all objects accessible to the current user. ALL_OBJECTS描述当前用户的可访问的 ...

  5. 【虚拟机-网络IP】保留正在使用的 VIP

    本文包含以下内容 适用场景 操作步骤 保留IP的费用 适用场景 我们希望云服务有一个固定的 IP,即使虚拟机以 deallocated 的方式关闭. 用户忘记先保留 VIP 而直接完成了部署. 希望不 ...

  6. Linux Shell流程例子

    #!/bin/bash read -p "input a dight:"echo $REPLY DATE=`date`echo "DATE is ${DATE}" ...

  7. SQL 字符串函数

    http://www.w3cschool.cn/sql/sql-string-functions.html SQL 字符串函数 序号 Name Description 备注 1 ASCII() 返回最 ...

  8. 突然心血来潮,想写写我在java面试中遇到的事。作为一个应届生,我觉得我的情况都与大部分应届生是差不多的,希望你们能在这上面得到一些有用的

    面试过程吧,怎么说呢?从一开始接触面试到现在成功了几家,这中间我确实收获了许多,那我就从我第一次面试开始讲吧. 第一次面试是有人介绍过来的,总之还是有一位贵人相助,所以第一次面试时,面试官很好没有怎么 ...

  9. A winner is a dreamer who never gives up

    A winner is a dreamer who never gives up. 成功者是坚持梦想不放弃的人.(Nelson Mandela)

  10. bzoj3209:3209: 花神的数论题

    觉得还是数位dp的那种解题形式但是没有认真的想,一下子就看题解.其实还是设置状态转移.一定要多思考啊f[i][j]=f[i-1][j]+g[i-1][j] g[i][j]=f[i-1][j-1]+g[ ...