摘要: 题目大意: 一共有n只蚯蚓,每只蚯蚓有一个长度,并且蚯蚓会按每年q厘米的速度增长。现在每年选择一只最长的蚯蚓,将其按p的比例切成两半,被切的的蚯蚓这一年不能增长,问每年被切的蚯蚓的长度和m年后所有蚯蚓的长度(据题意只需输出部分结果) 题目分析: 看到这题首先想到的是使用堆来做(因为,切蚯蚓符合堆的查 阅读全文
posted @ 2021-01-21 11:23 仰望星空的蚂蚁 阅读(36) 评论(0) 推荐(0)
摘要: #include<bits/stdc++.h> #define int long long using namespace std; const int N=200005; inline int read() { int X=0; bool flag=1; char ch=getchar(); wh 阅读全文
posted @ 2021-01-02 18:59 仰望星空的蚂蚁 阅读(7) 评论(0) 推荐(0)
摘要: #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> //Accepted??? using namespace std; const int N=2e5+5; const int Maxchar=26; cha 阅读全文
posted @ 2020-12-29 17:29 仰望星空的蚂蚁 阅读(13) 评论(0) 推荐(0)
摘要: solution: 很容易想到用回文自动机做。manacher算法也可以,但是我们这里不考虑。 但是这道题直接做并不好做。我的第一个思路是分两种情况讨论: 左端点或右端点重合,那么枚举一个左右端点即可包含或者交叉,枚举第一个回文子串 [ l , r ] [l,r] [l,r],然后计算区间 [ l 阅读全文
posted @ 2020-12-28 19:18 仰望星空的蚂蚁 阅读(13) 评论(0) 推荐(0)
摘要: #include<bits/stdc++.h> using namespace std; const int N=1e6+5; const int mod=19930726; struct node{ int len,fail,ch[26],siz; friend bool operator <(n 阅读全文
posted @ 2020-12-27 15:56 仰望星空的蚂蚁 阅读(11) 评论(0) 推荐(0)
摘要: 题目描述 给定一个长度为 n n n 的字符串 S S S,令 T i T_i Ti​ 表示它从第 i i i 个字符开始的后缀。求 ∑ 1 < = i < j < = n n l e n ( T i ​ ) + l e n ( T j ​ ) − 2 × l c p ( T i ​ , T j ​ 阅读全文
posted @ 2020-12-20 16:51 仰望星空的蚂蚁 阅读(12) 评论(0) 推荐(0)
摘要: 个人认为是比较简单的 d p dp dp。 首先,状态不难想,可求状态有这些:位数,前导零,limit标记,余数,满足条件的数的和,满足条件的数的平方和等。 其次,注意编程的细节。然后这道题就搞定了。 数位 d p dp dp的时间复杂度很好分析,就是所有可能的状态数。一般状态数 s s s<=1e 阅读全文
posted @ 2020-12-19 17:14 仰望星空的蚂蚁 阅读(19) 评论(0) 推荐(0)
摘要: 忘了博客地址了。 后续可能上升为总结。 代码比较复杂,细节很多,建议背下来。 【模板】AC自动机(简单版) 由势能分析可知,Query 部分时间复杂度是 O ( 2 ∗ l e n T ) O(2*lenT) O(2∗lenT) 统计 f a i l fail fail 答案部分是长度和,因为只统计 阅读全文
posted @ 2020-12-12 17:10 仰望星空的蚂蚁 阅读(11) 评论(0) 推荐(0)
摘要: https://blog.csdn.net/dyx404514/article/details/41831947 定义和KMP不一样,同时程序实现非常复杂。建议背下来。主要是利用 d p dp dp的思想。 时间复杂度证明:每个点只会被枚举一次。所以是 O ( n ) O(n) O(n)。 #inc 阅读全文
posted @ 2020-12-12 17:04 仰望星空的蚂蚁 阅读(11) 评论(0) 推荐(0)
摘要: https://blog.csdn.net/qq_43456058/article/details/94588721 这玩意和扩展KMP很像,都是利用了 d p dp dp和贪心的思想(选择最远覆盖距离)。同时利用了状态的相似性。然后类似于“镜面”的对称点转换,做到了 O ( n ) O(n) O( 阅读全文
posted @ 2020-12-12 17:01 仰望星空的蚂蚁 阅读(12) 评论(0) 推荐(0)