摘要: 错误: 1. z-algorithm 实现错误 2. 忘记给z[]清零 3. KMP 更容易 1 void z_algorithm(char *s, int n) { 2 int L = 0, R = 0; 3 for (int i = 1; i < n; ++i) { 4 if (i > R) { 阅读全文
posted @ 2017-09-20 02:21 大四开始ACM 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 错误: 1. 类似的题应该画图看一看 2. 漏掉边界情况,做题的时候可以先写下要考虑边界情况 阅读全文
posted @ 2017-09-20 00:53 大四开始ACM 阅读(80) 评论(0) 推荐(0) 编辑
摘要: 错误:pattern string 和 target string的大小开反了,看来还是要用一些比较有意义的变量名。 阅读全文
posted @ 2017-09-19 21:02 大四开始ACM 阅读(99) 评论(0) 推荐(0) 编辑
摘要: 错误: 1. 将数组模拟成string的时候,应在左后一个元素后面加一个endpos元素,模拟字符串的'\0' 2. KMP匹配的时候,状态应从 state = 0开始,而不是state = -1 3. MP 算法在构建fail数组的时候,f[i+1] = j+1, 而KMP在构建fail数组的时候 阅读全文
posted @ 2017-09-19 20:46 大四开始ACM 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 错误:没有考虑处理最后一个字符时的特殊情况。 阅读全文
posted @ 2017-09-19 18:03 大四开始ACM 阅读(96) 评论(0) 推荐(0) 编辑
摘要: 方法应该就是枚举一层房间数目所有情况,判定。 错误:题目理解错误,问题所求的是unique 结果,而不是unique一层房间的数目。 阅读全文
posted @ 2017-09-19 16:59 大四开始ACM 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 1. 每天做至少20题 2. 每天写总结 3. GRE 4. Ding教授的研究 阅读全文
posted @ 2017-09-19 16:07 大四开始ACM 阅读(130) 评论(0) 推荐(0) 编辑
摘要: https://codejam.withgoogle.com/codejam/contest/32004/dashboard A. Old Magician 方法: 打表找规律,发现结果只和black个数的奇偶性有关。 code: 1 #include <cstdio> 2 #include <cs 阅读全文
posted @ 2017-03-04 04:48 大四开始ACM 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 方法:dfs 染色 code: 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #include <iostream> 5 #include <string> 6 #include <vector> 7 #inclu 阅读全文
posted @ 2017-02-05 21:09 大四开始ACM 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 方法:dfs(flood fill) dfs code: 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #include <iostream> 5 #include <string> 6 #include <vec 阅读全文
posted @ 2017-02-05 19:32 大四开始ACM 阅读(119) 评论(0) 推荐(0) 编辑