数据结构
17ning
感谢您强迫我进步
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LA 3938( 线段树)
#include #include #include const int maxn = 500005; typedef long long ll; int n,m; ll a[maxn],sum[maxn]; struct node { int x,y,pre,suf,dx,dy; }; node tnode[maxn*2]; void Build(int o,int x,int y) {原创 2013-12-19 19:12:59 · 668 阅读 · 0 评论 -
poj1743(后缀数组)
本题需要对s数组做一下调整,然后求数组s中最常重复子串 #include #include const int maxn=20005; int s[maxn],rank[maxn],height[maxn],sa[maxn],wa[maxn],wb[maxn],wv[maxn],ws[maxn],n; int mind[maxn][15],maxd[maxn][15]; void adjust_原创 2014-03-10 13:58:54 · 743 阅读 · 0 评论 -
后缀数组
本代码只求出sa[ ], rank[ ], height[ ] #include #include const int maxn=200; char s[maxn];//假设字符串中出现的都是大写英文字母 int sa[maxn],rank[maxn],height[maxn],wa[maxn],wb[maxn],wv[maxn],ws[maxn],n; int cmp(int *r,int原创 2014-03-09 15:54:06 · 518 阅读 · 0 评论 -
poj3261(后缀数组求至少出现k次的最长子串可重叠)
思路:二分子串的长度。判断L长度的子串是否出现k的办法是对height数组进行分段, 分段的依据是height[ i ]>=L,若存在某段中元素的个数>=k-1,则存在长度为L的子串在主串中至少出现k次。#include #include #include #include using namespace std; const int maxn=20005; int s[maxn],rank[m原创 2014-03-10 19:51:31 · 756 阅读 · 0 评论 -
hdu2688树状数组
#include #include #include const int maxn=30000005; typedef __int64 ll; int n,a[maxn]; ll c[10005]; int lowbit(int x) { return x & (-x); } void Update(int x) { while(x<=10000) { c[x]+原创 2013-12-21 16:41:13 · 725 阅读 · 0 评论 -
hdu238树状数组
#include #include #include const int maxn=100005; typedef __int64 ll; struct node { ll s,num; }; node tnode[maxn]; int n; int lowbit(int x) { return x&(-x); } node find(int x) { node ans;原创 2013-12-21 14:00:52 · 544 阅读 · 0 评论 -
LA4329(树状数组)
#include #include #include using namespace std; const int maxn=100005; int a[maxn],c[maxn],mini1[maxn],mini2[maxn],n,m; int lowbit(int x) { return x&(-x); } int getsum(int x) { int ans=0; while(x>0原创 2013-12-14 23:32:55 · 565 阅读 · 0 评论 -
hdu2795线段树点修改
#include #include #include #define MIN(a,b) a>b?b:a const int maxn=200005; int h,w,n; struct node { int l,r,max; }; node tnode[maxn*4]; void Build(int o,int x,int y) { tnode[o].l=x; tnode[原创 2013-12-20 22:08:29 · 462 阅读 · 0 评论 -
hdu1394树状数组
#include #include #include const int maxn=50005; int a[maxn],c[maxn],n; int lowbit(int x) { return x&(-x); } int find(int x) { if(x>0) { return c[x]+find(x-lowbit(x)); } re原创 2013-12-20 21:08:30 · 503 阅读 · 0 评论 -
poj2155(树状数组)
#include #include const int maxn = 1005; int c[maxn][maxn],n,t,T; int lowbit(int x) { return x & (-x); } void update(int x,int y,int d) { if(x==0 || y==0) return; for(int i=x;i<=n;i+=lowbit(i)) {原创 2014-04-07 20:04:57 · 520 阅读 · 0 评论
分享