Design a data structure that supports the following two operations:
void addWord(word)
bool search(word)
search(word) can search a literal word or a regular expression string containing only letter...
分类:
其他好文 时间:
2015-08-09 12:36:57
阅读次数:
120
描述:给定N个字符串,求这些字符串的最长公共前缀长度与字符串的个数的乘积的最大值。 范围:1 2 using namespace std; 3 4 struct letter{ 5 char d;//节点存的字符 6 int son,bro;//左孩子和右兄弟,都是节点编号...
分类:
其他好文 时间:
2015-08-08 22:37:04
阅读次数:
144
Trie树简介:又称字典树、前缀树、单词查找树或键树,是一种用于快速检索的树形结构,是一种哈希树的变种
用途:
1、字符串检索:实现将一些字符串的有关信息保存到trie树中,查找另外一些字符串是否出现过或者出现的频率
2、前缀匹配:匹配前缀
3、排序:tire树是一颗多叉树,只需先序遍历整棵树,输出相应的字符串便是按字典序排序的结果
4、作为其他数据结构和算法的辅助结构:ac自动机、后缀...
分类:
其他好文 时间:
2015-08-08 12:10:46
阅读次数:
273
DescriptionIgnatius is so lucky that he met a Martian yesterday. But he didn't know the language the Martians use. The Martian gives him a history boo...
分类:
其他好文 时间:
2015-08-08 11:48:38
阅读次数:
128
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...
分类:
其他好文 时间:
2015-08-08 11:43:22
阅读次数:
98
Cellphone TypingTime Limit: 5000msMemory Limit: 131072KBThis problem will be judged onUVA. Original ID:1252664-bit integer IO format:%lld Java class n...
分类:
其他好文 时间:
2015-08-08 10:26:49
阅读次数:
124
Phone List
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 25160
Accepted: 7641
Description
Given a list of phone numbers, determine if it is consistent...
分类:
其他好文 时间:
2015-08-07 00:23:32
阅读次数:
311
这题不错,用到了三个知识点,我开始没用字典树,超时了。顺便学习了字典树。
看到了一个不错的题解。
可以用图论中欧拉路的知识来解这道题,首先可以把木棒两端看成节点,把木棒看成边,这样相同的颜色就是同一个节点
问题便转化为:
给定一个图,是否存在“一笔画”经过涂中每一点,以及经过每一边一次。
这样就是求图中是否存在欧拉路Euler-Path。...
分类:
其他好文 时间:
2015-08-06 22:25:27
阅读次数:
239
第一题:
Remember the Word
Time Limit: 3000MS
Memory Limit: Unknown
64bit IO Format: %lld & %llu
Submit Status
Description
Neal is very curious about combinato...
分类:
编程语言 时间:
2015-08-05 18:27:12
阅读次数:
246
题意:
给一个长度为5000的ab串,问你第k大的半回文子串是什么
所谓的半回文串就是下标是奇数的位置前后相等就好了。
思路:
首先发现串的长度只有5000,可以做一个类似区间dp的预处理
处理出dp[i][j]代表第i到j子串是不是半回文子串
然后依次把原串的所有子串插入字典树,并在节点标记个数
然后最后dfs一下k个就好了
代码:
#include"cstdlib"
#inc...
分类:
其他好文 时间:
2015-08-05 14:56:17
阅读次数:
107