- 博客(18)
- 收藏
- 关注
转载 Luogu P4122 [USACO17DEC]Blocked Billboard
Luogu P4122 [USACO17DEC]Blocked Billboard 解析 画图想一想,莫得想复杂咯! Code #include<cmath> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #defin...
2019-09-19 20:35:00
332
转载 Luogu P2181 对角线
Luogu P2181 对角线 解析 法一:每 4 个顶点会有一个交点,答案为 $ C_n^4 $ 法二:递推做差找规律 Code 法一 #include<cmath> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #...
2019-09-19 16:40:00
252
转载 Luogu P1652 圆
Luogu P1652 圆 解析 认真读题,注意任意两个圆都相离,而且是画曲线,也就是说只有点在圆内才会需要穿过圆的边界,否则绕过去就可以了 注意一种情况,起点和终点都在同一个圆内,那么这个圆可以不需穿过边界 判断一个点是否在圆内看它到圆心的距离是否小于半径 Code #include<cmath> #include<cstdio> #include&l...
2019-09-19 16:24:00
225
转载 Luogu P2651 添加括号III
Luogu P2651 添加括号III 解析 $ a_1 $ 肯定是分子,$ a_2 $ 肯定是分母,那么尽可能多的是 $ a_3 $ 以后的变为分子 $ a_1 / ( a_2 / a_3 / a_4 / ... ) = a_1 a_3 a_4 ... / a_2 $,所以我们只要确认 $ a_1 a_3 a_4 ... / a_2 $ 是否是整数 进行约分,若 $ a_2 $...
2019-09-18 21:32:00
212
转载 从“四人过桥”到“N人过桥”
手电筒—过桥问题 四人过桥+一个手电筒 解析 考虑图论的方法,以桥的另一边有哪几个人为状态建点,按照规则连边并加上权值,然后从对岸没有人的状态点到四个人都在对岸的状态点跑最短路,最短路长度即为答案 我这里的建点和建图都有些麻烦而且不易推广, wyxdrqc 大佬说可以用一个四位二进制数来表示状态, x 号人在对岸则他对应的第 x 位为 1 ,否则为 0 ,这里没有尝试代码实...
2019-09-16 15:19:00
232
转载 Luogu P2375 [NOI2014]动物园
Luogu P2375 [NOI2014]动物园 解析 KMP 的神奇应用 Code #include<cmath> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define LL long long using ...
2019-09-12 11:35:00
122
转载 Luogu P3435 [POI2006]OKR-Periods of Words
Luogu P3435 [POI2006]OKR-Periods of Words 解析 KMP 中 next 数组的神奇应用 Code #include<cmath> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #...
2019-09-11 21:38:00
143
转载 Luogu P4391 [BOI2009]Radio Transmission 无线传输
Luogu P4391 [BOI2009]Radio Transmission 无线传输 解析 KMP找最大循环节的长度 ans = n - next[n] Code #include<cmath> #include<cstdio> #include<cstring> #include<iostream> #include<...
2019-09-11 21:35:00
221
转载 Luogu P4555 [国家集训队]最长双回文串
Luogu P4555 [国家集训队]最长双回文串 解析 看到回文串,先想 Manacher(马拉车) 算法 题目中要求最长双回文串的长度,注意这个双回文串不能有重叠部分,所以我们想到 Manacher 后枚举切断的位置,这个位置只能是 “ # ” ,为了防止时间复杂度退化到 $ n^2 $ ,我们开两个数组 aft 和 bef , $ aft_i $ 表示以 i 为左端点( i...
2019-09-11 15:59:00
154
转载 Luogu P1659 [国家集训队]拉拉队排练
Luogu P1659 [国家集训队]拉拉队排练 解析 题意简单来说就是找所有回文串,按长度从大到小排序后将前K个长度乘起来 看到回文串问题,由于我太菜了,只会Manacher算法,所以只能用Manacher来做这道题了 注意K的数据范围 1e12,long long !!! 快速幂求结果 Code #include<cmath> #include<cstdi...
2019-09-07 16:51:00
140
转载 AC自动机
本文共三道题目,都是 $ AC $ 自动机的模板题 初学AC自动机,AC自动机可以理解为“Trie树上KMP”(所以要先学会Trie树和KMP哦!) 1.Luogu P3808 【模板】AC自动机(简单版) Code #include<cmath> #include<cstdio> #include<cstring> #include...
2019-09-07 11:03:00
125
转载 KMP
Luogu P3375 【模板】KMP字符串匹配 Code #include<cmath> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define LL long long using namespace std; co...
2019-09-06 16:24:00
142
转载 Luogu P1470 最长前缀 Longest Prefix
Luogu P1470 最长前缀 Longest Prefix 注释 这道题与上一篇博客的题几乎一样 解析 有点麻烦的地方就是字符串的输入 方法一:类dp Code #include<cmath> #include<cstdio> #include<cstring> #include<iostream> #include<alg...
2019-09-06 15:35:00
186
转载 Luogu P2292 [HNOI2004]L语言
Luogu P2292 [HNOI2004]L语言 解析 看到单词和句子匹配,再看数据范围1M的字符串(长度大约 $ 10^6 $ 级别),所以用Trie树来处理 句子是没有标点符号的,所以需要我们自己断句,那么我们先将所有单词加入Trie树,然后让句子在树上匹配,匹配时可不可以匹配完一个单词就将其从句子中删掉呢? 上面这个问题的回答是:NO,因为上面这个想法是一种贪心的思想,有可能...
2019-09-06 10:57:00
132
转载 Manacher算法
Luogu P3805 【模板】manacher算法 初学 $ Manacher $ (马拉车)算法 Manacher算法用于处理回文串问题,可以求出每个字符所在的最长回文串的长度 Code #include<cmath> #include<cstdio> #include<cstring> #include<iostream...
2019-09-05 19:47:00
113
转载 字典(Trie)树
本文共三道题目,都算是 $ Trie $ 树的模板题 1.Libre 10049 Phone List Code #include<cmath> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define LL long ...
2019-09-05 18:58:00
105
转载 逆序对
1.Luogu P1908 逆序对 归并排序 #include<cmath> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define LL long long using namespace std; const i...
2019-09-05 18:17:00
135
转载 声明
Welcome to my blog!!! 本人是位名副其实的蒟蒻,因为实力太差,博客中难免会出现错误,请各位见谅 转载于:https://www.cnblogs.com/Hawking-llfz/p/11467082.html...
2019-09-05 16:45:00
111
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅