摘要: /* 裸地manachar */ #include #include #include #define maxn 1000010 using namespace std; int l,len[maxn]; char s[maxn],ss[maxn]; int manachar() { int ans=0; int id=-1,mx=-1; for(int i=1;i=0... 阅读全文
posted @ 2016-05-09 21:03 一入OI深似海 阅读(134) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #define maxn 1010 using namespace std; int ans,an[maxn],l1,l2,fail[maxn]; char s1[maxn],s2[maxn]; void kmp_init() { for(int i=2;i<=l2;i++) { int p=fail[... 阅读全文
posted @ 2016-05-09 18:11 一入OI深似海 阅读(145) 评论(0) 推荐(0) 编辑
摘要: /* 无奈我改了那么久还是看的题解 首先跑一边kmp 几下ans[p]表示总共匹配到长度p的次数 这些不一定都是恰好到p 所以在处理一下 ans[p]通过处理变成 所有的匹配到长度p的次数 最后答案就是总共匹配到长度p+1的次数 - 总共匹配到长度p的次数 就是恰好匹配到长度p的次数 */ #include #include #include #define maxn 200010 usin... 阅读全文
posted @ 2016-05-09 18:09 一入OI深似海 阅读(278) 评论(0) 推荐(0) 编辑
摘要: /* 手打的哈希+线性的维护 第一问:hash一下 并且用个h记录某个单词要背的 第二问:线性的跑一边 开始队列里装下前一些单词使这一坨符合要求 并且记录出现次数num 然后开始从前面删 删除的条件:要么是非法的单词(h值为0) 要么num值大于1 如果删不了就在进来一个 更新num 直到跑完 这过程中每次更新l 注意这样有极端数据 如果第一问答案为 0 需要特判... 阅读全文
posted @ 2016-05-08 17:41 一入OI深似海 阅读(227) 评论(0) 推荐(0) 编辑
摘要: /* n*n的算法 比较容易想到 特判的好cena的 70分 */ #include #include #include using namespace std; int a[40005],f[40005]; int main() { //freopen("cleanup.in","r",stdin); //freopen("cleanup.out","w",stdout)... 阅读全文
posted @ 2016-05-08 16:03 一入OI深似海 阅读(206) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #define maxn 100010 using namespace std; int n,m,num; struct node { int lc,rc; int l,r; int sum,bj; }t[maxn*2+100]; void Build(int ll,int rr) { int... 阅读全文
posted @ 2016-05-07 22:26 一入OI深似海 阅读(212) 评论(0) 推荐(0) 编辑
摘要: /* 线段树开到*4 *4 *4 *4 ! 维护 4个值 区间最大值 区间最小值 从左往右跑最大收益 从右往左跑最大收益 */ #include #include #include #define maxn 200010 #define inf 0x7fffffff using namespace std; int n,m,num,a[maxn]; struct node { int ... 阅读全文
posted @ 2016-05-07 21:09 一入OI深似海 阅读(174) 评论(2) 推荐(0) 编辑
摘要: /* b本树较弱 支持插入+查询(删除太麻烦0.0) 复杂度 对于随机数据O(n*logn) 特殊的 如果一条链下来 O(n*n) (升级版:平衡树. ) */ #include #include #include #define maxn 100010 using namespace std; struct node { int lch; int rch; int ... 阅读全文
posted @ 2016-05-05 22:09 一入OI深似海 阅读(210) 评论(0) 推荐(0) 编辑
摘要: /* 差分序列 b[i]=a[i]-a[i-1] 支持多次区间+ / - 最后输出原序列 区间+ 只需要修改 b[l] b[r+1] */ #include #include #define maxn 200010 using namespace std; int n,a[maxn],b[maxn],m; int init() { int x=0; int f=0; ... 阅读全文
posted @ 2016-05-05 22:06 一入OI深似海 阅读(200) 评论(0) 推荐(0) 编辑
摘要: /* 树状数组前缀和 虽然只资词单点修改 区间查询 但是好写 pos&(-pos) 很神奇的东西 求前缀和 负数的二进制表示用补码(对应整数的反码+1) */ #include #include #include using namespace std; int tree[100010],n,m; void Add(int pos,int data) { while(pos>n; ... 阅读全文
posted @ 2016-05-05 22:03 一入OI深似海 阅读(133) 评论(0) 推荐(0) 编辑