摘要: 传送门: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) 编辑