数据结构
lyjvactor
弱菜求轻虐==
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
poj_2828线段树,逆序插入
#include#include#include#include#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1const int maxn = 200020;using namespace std;int p[200020],v[200020];int sum[maxn<<2];int ans[maxn];void build原创 2014-08-09 12:50:05 · 395 阅读 · 0 评论 -
poj_3667线段树区间合并
对照着notonlysuccess大牛的代码写的原创 2014-11-02 19:51:32 · 394 阅读 · 0 评论 -
hdu_2871
#include#include#include#include#include#include#define lson r,m,rt<<1#define rson m+1,r,rt<<1|1const int maxn=55555;using namespace std;int lsum[maxn<<2],rsum[rt<<2],sum[rt<<2];void pushUp原创 2014-11-14 09:42:09 · 457 阅读 · 0 评论 -
hdu_3308 区间合并
一两个月没写代码的确是手生的厉害,原创 2014-11-06 19:59:08 · 426 阅读 · 0 评论 -
uva_127,栈以及vector的应用
参考自http://www.cnblogs.com/maqiang/archive/2012/05/02/2479760.html原创 2014-09-02 14:12:13 · 460 阅读 · 0 评论 -
hdu_1754,线段树单点更新,求区间最值
http://www.notonlysuccess.com/index.php/segment-tree-complete/#include#include#include#include#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define maxn 2222222using namespace std;int a[maxn原创 2014-09-10 17:51:46 · 477 阅读 · 0 评论 -
poj_3468,线段树成段更新
参考自http://www.notonlysuccess.com/index.php/segment-tree-complete/原创 2014-09-13 20:52:26 · 378 阅读 · 0 评论 -
hdu_1394,线段树求逆序数
http://www.notonlysuccess.com/index.php/segment-tree-complete/#include#include#include#include#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;const int maxn=5555;int sum[ma原创 2014-09-11 20:02:25 · 451 阅读 · 0 评论 -
hdu_2795,线段树,单点更新
#include#include#include#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;const int maxn=222222;int seq[maxn<<2];int h,w;void pushUp(int rt){ seq[rt]=max(seq[rt<<1],seq原创 2014-09-12 07:43:56 · 433 阅读 · 0 评论 -
hdu_1166,线段树单点更新
在刷线段树,参考自http://www.notonlysuccess.com/index.php/segment-tree-complete/原创 2014-09-10 12:22:07 · 470 阅读 · 0 评论 -
poj_2481,Cows,树状数组
将e按从大到小排序,统计原创 2014-09-09 21:19:49 · 434 阅读 · 0 评论 -
poj_1974,最长回文字串manacher
时间复杂度为O(n),参考:http://bbs.dlut.edu.cn/bbstcon.php?board=Competition&gid=23474#include#include#include#include#define maxn 2001000using namespace std;char s[maxn],st[maxn];int p[maxn];int cases=原创 2014-08-23 12:21:24 · 497 阅读 · 0 评论 -
poj_1195Mobile phones,二维树状数组
#include#include#include#includeusing namespace std;int a[1300][1300];int s;int lowbit(int x){ return x&(-x);}void add(int x,int y,int d){ for(int i=x;i<=s;i+=lowbit(i)) for(int原创 2014-09-05 20:11:16 · 422 阅读 · 0 评论 -
poj_2299Ultra-QuickSort,树状数组离散化
求逆序数#include#include#include#includeusing namespace std;struct node{ int num; int pos;};node st[500010];int reflect[500010];int a[500010];int n;bool cmp(node a,node b){ return原创 2014-09-04 22:14:39 · 451 阅读 · 0 评论 -
poj_2352树状数组
因为y已经排好序了,用x坐标ji原创 2014-08-11 18:20:23 · 360 阅读 · 0 评论 -
poj_3468线段树成段更新求区间和
#include#include#includelong long num[100010];using namespace std;struct st{ int l; int r; long long sum; long long a;} p[400100];void build(int t,int l,int r){ p[t].l=l;转载 2014-05-20 14:21:08 · 573 阅读 · 0 评论 -
uva_644暴力加字典树解法
暴力#include#include#includeusing namespace std;int main(){ int t=0,i=0; char s[10][12]; bool a[12][12]; memset(s,'\0',sizeof(s)); while(scanf("%s",s[i])!=EOF) { if(原创 2014-05-05 20:36:02 · 509 阅读 · 0 评论 -
hdu_1698线段树成段更新
#include#include#include#include#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;const int maxn=100100;int sum[maxn<<2],col[maxn<<2];void pushUP(int rt){ sum[rt]=sum[r原创 2014-08-09 19:58:49 · 405 阅读 · 0 评论 -
poj_2777线段树+位运算
第一次没想到用位运算,不原创 2014-11-02 12:22:03 · 466 阅读 · 0 评论
分享