Hat’s Words
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9620 Accepted Submission(s): 3438
Problem Description
A hat’s word is a ...
分类:
其他好文 时间:
2015-07-20 14:33:04
阅读次数:
172
看之前先看下trie树是怎么构造的树上的词分别是(从上到下){ he , hers , his , she}按图所示分成3层看到第三层是"she"其中,①s指向root ②h先找到s的fail指针,发现是0号指针,不是h,然后h就不高兴了,再问问s的fail指针root:“你有没有儿子和我同名叫h的...
分类:
其他好文 时间:
2015-07-19 21:40:09
阅读次数:
128
Trie 树 中文名叫字典树,可以用来存放n个单词,并且找出某个前缀的数量,或者找出某个单词的数量。其实也有其他的应用,比如统计有多少个不同的字符串等等。字典树分为一般分为两个部分,一个是创建字典树,还一个是find函数,find函数的写法随着题目要求可以灵活多变的!首先 要先定义出数据结构。1 ....
分类:
其他好文 时间:
2015-07-17 09:40:24
阅读次数:
187
1. 使用 Map比使用Set可以省去查找(遍历)2. 逻辑上 查找一个word, 是遍历word的每一个字符。 不是遍历 tree.拿到一个字符时,直接使用map.containsKey(x);过程: 遍历 --> word : "cbd" (非无限,到word末尾自然结束循环遍历) 当前节点.....
分类:
其他好文 时间:
2015-07-16 21:31:35
阅读次数:
102
What Are You Talking About
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 102400/204800 K (Java/Others)
Total Submission(s): 16042 Accepted Submission(s): 5198
Problem Descriptio...
分类:
其他好文 时间:
2015-07-16 14:11:23
阅读次数:
109
题意:实现trie树的3个功能,只含小写字母的串。思路:老实做即可! 1 class TrieNode { 2 public: 3 TrieNode* chd[26]; 4 bool flag; 5 // Initialize your data structure her...
分类:
其他好文 时间:
2015-07-16 00:48:37
阅读次数:
150
搞了一晚上AC自动机,发现需要先学trie和kmp……都不会啊。。于是又去现学KMP和trie。。终于基本看懂AC自动机了。#include using namespace std;struct node{ int next[26];//每一个节点可以扩展到的字母 int fail;//...
分类:
其他好文 时间:
2015-07-15 22:20:46
阅读次数:
109
题目链接一A,开森~ac代码: 1 class TrieNode { 2 // Initialize your data structure here. 3 char content; 4 boolean isWord; 5 int count; 6 Link...
分类:
其他好文 时间:
2015-07-14 21:59:57
阅读次数:
150
3942 - Remember the Word
Neal is very curious about combinatorial problems, and now here comes a problem about words. Knowing that Ray has a photographic memory and this may not trouble him, Neal...
分类:
其他好文 时间:
2015-07-14 18:07:32
阅读次数:
156
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2832
题意:模拟strcmp()函数,给n个字符串,两两之间进行比较,问需要进行多少次比较?
解析:字符串很多,数据量大,按题意两两比较显然不现实。如果把所有的单词插入到一棵Tr...
分类:
其他好文 时间:
2015-07-14 11:42:09
阅读次数:
95