随笔分类 -  字符串

摘要:题意:给定一些木棒,木棒两端都涂上颜色,求是否能将木棒首尾相接,连成一条直线,要求不同木棒相接的一边必须是相同颜色的。 无向图存在欧拉路的充要条件为: ① 图是连通的; ② 所有节点的度为偶数,或者有且只有两个度为奇数的节点。 图的连通可以利用并查集去判断。 度数的统计比较容易。 代码实现 //第一次用指针写trie,本来是用二维数组,发现数组开不下,只好删... 阅读全文
posted @ 2014-08-08 10:55 ForeverEnjoy 阅读(152) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2014-08-07 11:12 ForeverEnjoy 阅读(2) 评论(0) 推荐(0)
摘要:KMP,在有循环节的前提下: 循环节 t = len-next[len], 个数num = len/(len-next[len]);个人理解,如果有循环节,循环节长度必定小于等于len/2, 换句话说next[len]>=len/2;对于len%(len-next)!=0的这种情况不讨论,循环节不存在。下面是假设循环节存在的情况当次数等于2, 对于abcabc这种情况就不用说了,len = 6,... 阅读全文
posted @ 2014-08-07 10:46 ForeverEnjoy 阅读(183) 评论(0) 推荐(0)
摘要:hdu 3374 String Problem 最小表示法 view code#include #include #include #include #include #include using namespace std; const int N = 10010; int n; char s[105]; mapma; void getminsub(char *s) { ... 阅读全文
posted @ 2014-08-07 09:29 ForeverEnjoy 阅读(185) 评论(0) 推荐(0)
摘要:PeriodTime Limit: 3000MSMemory Limit: 30000KTotal Submissions: 12089Accepted: 5656DescriptionFor each prefix of a given string S with N characters (ea... 阅读全文
posted @ 2014-03-21 20:01 ForeverEnjoy 阅读(217) 评论(0) 推荐(0)
摘要:Power StringsTime Limit: 3000MSMemory Limit: 65536KTotal Submissions: 29663Accepted: 12387DescriptionGiven two strings a and b we define a*b to be the... 阅读全文
posted @ 2014-03-21 13:24 ForeverEnjoy 阅读(2772) 评论(2) 推荐(3)