上一页 1 2 3 4 5 6 ··· 26 下一页
摘要: 传送门:http://hihocoder.com/problemset/problem/1415 【题解】 考虑求出两串合在一起(中间加分隔符)后缀数组,就是要求任意在两个串中的$i, j$,$\min\{h_k\} (i \leq k \leq j)$的最大值。 考虑$i, j$一定是满足$|i 阅读全文
posted @ 2017-07-18 06:46 Galaxies 阅读(225) 评论(0) 推荐(0) 编辑
摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3172 【题解】 考虑建出AC自动机,那么fail树上每个点的父亲为fail,父亲->儿子为后缀关系(父亲是儿子后缀) 那么走到父亲肯定走到了儿子,直接统计即可。 # include <queu 阅读全文
posted @ 2017-07-17 22:41 Galaxies 阅读(243) 评论(0) 推荐(0) 编辑
摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1430 【题解】 考虑带标号无根树计数,总共是$n^{n-2}$种。 考虑顺序问题,一共是$(n-1)!$种,所以答案是$n^{n-2} * (n-1)!$。 复杂度$O(n)$ # inclu 阅读全文
posted @ 2017-07-17 21:48 Galaxies 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2038 【题解】 莫队出的裸莫队。 # include <math.h> # include <stdio.h> # include <string.h> # include <iostream 阅读全文
posted @ 2017-07-16 15:16 Galaxies 阅读(263) 评论(0) 推荐(0) 编辑
摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2844 【题解】 考虑$n$个数组成的基,大小为$k$,那么每种方案都有$2^{n-k}$可以取到。 观察样例也能发现这个结论。 然后就是正常的线性基统计,最后乘一个$2^{n-k}$,加一即可 阅读全文
posted @ 2017-07-16 15:02 Galaxies 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3224 【题解】 写起来跟*一样,但是还是挺快调出来了。 主要就是每个数可以有多个,我们可以用一个splay节点存多个数,然后find即可。 注意的是每个操作过后基本都要splay一下保证复杂度 阅读全文
posted @ 2017-07-16 11:12 Galaxies 阅读(242) 评论(0) 推荐(0) 编辑
摘要: 传送门:http://poj.org/problem?id=2096 【题解】 看到有人在uoj群上问这个……就去看了看… 顺便复习下概率dp $f_{i,j}$表示这个人已经找出了$i$种系统的bug,和$j$种bug的期望步数。 每次有4种转移: 1. 发现了新的bug种类,属于新的系统,那么是 阅读全文
posted @ 2017-07-15 21:00 Galaxies 阅读(226) 评论(0) 推荐(0) 编辑
摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3083 【题解】 树链剖分,然后换根+询问子树这个是经典套路,分类讨论即可。 复杂度$O(nlog^2n)$ # include <stdio.h> # include <string.h> # 阅读全文
posted @ 2017-07-15 19:57 Galaxies 阅读(226) 评论(0) 推荐(0) 编辑
摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3524 http://www.lydsy.com/JudgeOnline/problem.php?id=2223 【题解】 由于出现次数超过区间长度的一半的数最多只有1个,所以就可以分两半找了。 阅读全文
posted @ 2017-07-15 17:50 Galaxies 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 传送门:http://uoj.ac/problem/311 【题解】 这题的期望dp好神奇啊(可能是我太菜了) 由于每个位置都完全一样,所以我们设$f_{i,j}$表示审了连续$i$个位置,最大值不超过$j$的期望。 那么只要考虑最大值为$j$的期望,其他从$f_{i,j-1}$加进来即可。 枚举最 阅读全文
posted @ 2017-07-15 15:20 Galaxies 阅读(407) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 26 下一页