hdu1305 字典树水题】的更多相关文章

题意:      给你一些字符串,然后问你他们中有没有一个串是另一个串的前缀. 思路:       字典树水题,(这种水题如果数据不大(这个题目不知道大不大,题目没说估计不大),hash下也行,把每个串拆成len个串,然后map容器记录下就行了,不想存也 行,最后迭代一下也能出来),回来说字典树,就是最简单的前缀判断应用,我写的结构体里面有3个量,next[], v(出现次数) ,mk (是不是某个字符串的最后一位), 在查找的时候如果我们碰到了已经mk的,那么就直接发现前缀了,某个字符串是当前…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1247 Problem DescriptionA hat’s word is a word in the dictionary that is the concatenation of exactly two other words in the dictionary.You are to find all the hat’s words in a dictionary. InputStandard…
题目链接 B - 秋实大哥与快餐店 Time Limit:1000MS     Memory Limit:65535KB     64bit IO Format:%lld & %llu Submit Status Practice UESTC 1060 Appoint description:  System Crawler  (2016-04-24) Description 朝为田舍郎,暮登天子堂.秋实大哥从小就怀抱有远大的理想,所以他开了一家快餐店. 秋实大哥根据菜的口感,给每一道菜一个唯一…
http://acm.hdu.edu.cn/showproblem.php?pid=1251 建树之后 查询即可. G++提交 ME不知道为什么,c++就对了. #include <iostream> #include <cstdio> #include <cmath> #include <vector> #include <cstring> #include <string> #include <algorithm> #…
https://vjudge.net/problem/HDU-1251 标准的字典树模板题: 也注意一下输入方法: #include<iostream> #include<cstdio> #include<cstring> using namespace std; ; struct node { int num; node *next[maxn]; }; //字典树 class Tree{ public: node *head; //构造函数 Tree() { head…
题目链接:传送门 描述给定 $N$ 个字符串 $S_1,S_2,\cdots,S_N$,接下来进行 $M$ 次询问,每次询问给定一个字符串 $T$,求 $S_1 \sim S_N$ 中有多少个字符串是 $T$ 的前缀.输入字符串的总长度不超过 $10^6$,仅包含小写字母. 输入格式第一行两个整数 $N,M$.接下来 $N$ 行每行一个字符串 $S_i$.接下来 $M$ 行每行一个字符串表示询问. 输出格式对于每个询问,输出一个整数表示答案 样例输入3 2abbcabcabcefg 样例输出20…
http://acm.hdu.edu.cn/showproblem.php?pid=1251 题意:给出一些单词,然后有多次询问,每次输出以该单词为前缀的单词的数量. 思路: 字典树入门题. #include<iostream> #include<cstdio> #include<cstring> using namespace std; ; ; struct Trie { ]; int cnt; //前缀数量 int ends; //单词数量,在本题中其实并没有用到…
A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 135904   Accepted: 42113 Case Time Limit: 2000MS Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type o…
>>点击进入原题测试<< 思路:线段树水题,可以手敲 #include<string> #include<iostream> #include<algorithm> #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 using namespace std; ; ]; void build(int l, int r, int rt) { if (l == r){ cin &g…
/******************************************************* 题目: 统计难题 (hdu 1251) 链接: http://acm.hdu.edu.cn/showproblem.php?pid=1251 算法: 字典树 提示: 这题压要用c++提交,G++会超内存 *******************************************************/ #include<cstdio> #include<cstr…