上一页 1 2 3 4 5 6 ··· 13 下一页
摘要: 先把所有词扔进tire,然后dfs序弄出区间,然后就是区间最大值了 主席树各种写挂QAQ 1 #include<bits/stdc++.h> 2 #define inc(i,l,r) for(int i=l;i<=r;i++) 3 #define dec(i,l,r) for(int i=l;i>= 阅读全文
posted @ 2016-02-25 18:36 onlyRP 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 开学了,不能愉快地刷题了QAQ 差分约束(以前用并查集做真是作死。。)然后有个点比较坑,要过的话就要倒着加边,否则TLE 1 #include<bits/stdc++.h> 2 #define inc(i,l,r) for(int i=l;i<=r;i++) 3 #define dec(i,l,r) 阅读全文
posted @ 2016-02-21 17:22 onlyRP 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 单词建出AC自动机,然后在自动机上做DP d[i][j]表示第i个字符匹配到节点j上的方案数 直接算有点麻烦,统计不满足的方案数就好了 1 #include<bits/stdc++.h> 2 #define inc(i,l,r) for(int i=l;i<=r;i++) 3 #define dec 阅读全文
posted @ 2016-02-17 00:05 onlyRP 阅读(146) 评论(0) 推荐(0) 编辑
摘要: AC自动机入门题,只是上来传个模板。。。 1 //#include<bits/stdc++.h> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<iostream> 6 #include<queue> 7 阅读全文
posted @ 2016-02-16 15:22 onlyRP 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 设a[i]为前缀和,则i~j的异或和为a[j]^a[i],对于2个只需把另一个当成后缀就可以了 求max(a[j]^a[i])的话就用tire维护就可以了 1 #include<bits/stdc++.h> 2 #define inc(i,l,r) for(int i=l;i<=r;i++) 3 # 阅读全文
posted @ 2016-02-15 00:02 onlyRP 阅读(244) 评论(0) 推荐(0) 编辑
摘要: tire入门,死得好惨。。。 1 #include<bits/stdc++.h> 2 #define inc(i,l,r) for(int i=l;i<=r;i++) 3 #define dec(i,l,r) for(int i=l;i>=r;i--) 4 #define link(x) for(e 阅读全文
posted @ 2016-02-14 20:48 onlyRP 阅读(230) 评论(0) 推荐(0) 编辑
摘要: 很明显直接二维是作死的。。所以给按X点排下序,当然离线处理询问时差分的点会方便些。。 对Y坐标就用BIT维护就行。。 但由于坐标比较大,所以还要离散化= = 处理起来略麻烦但代码并不难写 1 //#include<bits/stdc++.h> 2 #include<cstdio> 3 #includ 阅读全文
posted @ 2016-02-13 22:57 onlyRP 阅读(276) 评论(0) 推荐(0) 编辑
摘要: 和上道差不多,离线处理,然后扫一遍序列,扫到就数先不增加,上个相同的数+1,上上个数-1,用BIT维护前缀和 静态差错要多练练。。。 1 //#include<bits/stdc++.h> 2 #include<cstdio> 3 #include<cstring> 4 #include<algor 阅读全文
posted @ 2016-02-13 16:10 onlyRP 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 用DP直接求LCS明显超时,这题和平时的区别在与给定了数,所以从这入手可以直接记录各数字的位置 然后依次填入dp[i]=max{dp[j]}+1(1<=j<=i)用BIT维护最大值O(nlogn) 1 //#include<bits/stdc++.h> 2 #include<cstdio> 3 #i 阅读全文
posted @ 2016-02-13 00:51 onlyRP 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 这题的做法有点神奇。。 离线处理。按r排序,记录上个相同的数出现的位置,边加入一个数的同时删去上一个相同的数就好了。。用BIY维护和 BIT写起来挺快的。。 1 //#include<bits/stdc++.h> 2 #include<cstdio> 3 #include<cstring> 4 #i 阅读全文
posted @ 2016-02-12 21:23 onlyRP 阅读(148) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 13 下一页