摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1686 用KMP查找模式串在目标串中出现的次数。 我的KMP模板(感觉这样统一比较好记) 1 #include<cstdio> 2 #include<cstring> 3 const int maxn=1 阅读全文
posted @ 2017-03-24 21:18 yijiull 阅读(499) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1711 KMP模板题。 一篇很不错的关于KMP的讲解,认真看完可以掌握KMP,但是nex数组和平时用的不太一样(不建议用这个)。 另外一篇KMP,也很不错。 刚知道有一个函数:strstr()很好用,有需 阅读全文
posted @ 2017-03-24 21:14 yijiull 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2612 第一次做的时候我是遍历图,碰到@就bfs一次,找到两个目标点的距离之和。 但是,有可能@很多很多,会TLE!! 看了别人题解,只要两次bfs即可。 从两个起点开始bfs,记录下起点到每一个@的距离 阅读全文
posted @ 2017-03-24 20:54 yijiull 阅读(100) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1495 每次六种决策,见注释。 vis开二维就够用了,因为水的总量是一定的 阅读全文
posted @ 2017-03-24 20:39 yijiull 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1241 用dfs求连通块。 有兴趣可以看这道关于连通块的题:https://hihocoder.com/problemset/problem/1310 题解: 1 #include<cstdio> 2 # 阅读全文
posted @ 2017-03-24 20:34 yijiull 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=3984 比较简单,我是用string记录每次走的方向,最后输出。 阅读全文
posted @ 2017-03-24 20:28 yijiull 阅读(956) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=3414 很有趣的题目。 每次六种决策,下面注释中已说明。 用string记录路径。 用二维vis数组记录两个杯子的状态,避免重复。 阅读全文
posted @ 2017-03-24 20:24 yijiull 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=3087 模拟题,用set判断是否出现重复,如重复则输出-1(因为会一直循环,达不到最终结果)。 用string写了一遍,和上面差不多。 阅读全文
posted @ 2017-03-24 20:10 yijiull 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=3126 每次四种决策,千位||百位||十位||个位。 其实各位数字不用存进结构体里,每次算一下就好 阅读全文
posted @ 2017-03-24 20:00 yijiull 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=3278 每次有三种决策:加一||减一||乘二。 阅读全文
posted @ 2017-03-24 19:49 yijiull 阅读(89) 评论(0) 推荐(0) 编辑