随笔分类 -  字典树

codeforces 455B A Lot of Games(博弈,字典树)
摘要:题目大意:给定n,表示字符串集合。给定k,表示进行了k次游戏,然后是n个字符串。每局开始,字符串为空串,然后两人轮流在末尾追加字符,保证新的字符串为集合中某字符串的前缀,不能操作者输,新一轮由上一句输的人先手。解题思路:首先对字符集合建立字典树,然后根据博弈的必胜必败性质搜索出先手的决策状态,可决定... 阅读全文

posted @ 2014-08-13 23:22 雄.. 阅读(250) 评论(0) 推荐(0)

hust 1605 - Gene recombination(bfs+字典树)
摘要:1605 - Gene recombinationTime Limit:2sMemory Limit:64MBSubmissions: 264 Solved: 46DESCRIPTIONAs a gene engineer of a gene engineering project, Enigma ... 阅读全文

posted @ 2014-05-28 14:03 雄.. 阅读(206) 评论(0) 推荐(0)

La 4670 AC自动机(模版)
摘要:#include#include#include#include#include#includeusing namespace std;const int SIGMA_SIZE = 26;const int MAXNODE = 11000;const int MAXS = 150 + 10;map ms;struct AhoCorasickAutomata{ int ch[MAXNODE][SIGMA_SIZE]; int f[MAXNODE]; // fail函数 int val[MAXNODE]; // 每个字符串的结尾结点都有一个非0的val int la... 阅读全文

posted @ 2014-03-27 14:04 雄.. 阅读(187) 评论(0) 推荐(0)

uva 11732 (trie树)
摘要:题意:求N个字符串两两比较,共比较了多少次?#include#include#includeusing namespace std;typedef long long LL;const int maxnode = 4000 * 1000 + 10;// 字母表为全体小写字母的Triestruct Trie{ int head[maxnode]; // head[i]为第i个结点的左儿子编号 int next[maxnode]; // next[i]为第i个结点的右兄弟编号 char ch[maxnode]; // ch[i]为第i个结点上的字符 int tot[max... 阅读全文

posted @ 2014-03-26 17:56 雄.. 阅读(186) 评论(0) 推荐(0)

hdu 1251 统计难题
摘要:统计难题Time Limit: 4000/2000 MS (Java/Others)Memory Limit: 131070/65535 K (Java/Others)Total Submission(s): 12283Accepted Submission(s): 5175Problem DescriptionIgnatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀).Input输入数据的第一部分是一张单词表,每行一个单词,单词的长度不超过10,它们代表的是老师交给Ignatius统 阅读全文

posted @ 2013-04-15 12:45 雄.. 阅读(154) 评论(0) 推荐(0)

hud 1671 Phone LIst
摘要:Phone ListTime Limit: 3000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6258Accepted Submission(s): 2130Problem DescriptionGiven a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let’s say the phone cata 阅读全文

posted @ 2013-04-15 12:41 雄.. 阅读(174) 评论(0) 推荐(0)

导航