摘要: 简单的线段树的题;有两种方法写这个题,目前用的熟是这种慢点的;不过不知道怎么老是T;感觉网上A过的人的时间度都好小,但他们都是用数组实现的难道是指针比数组慢?好吧,以后多用数组写写吧!超时的代码: 1 #include 2 #include 3 #include 4 #define maxn 1000009 5 using namespace std; 6 7 struct node 8 { 9 int l,r; 10 int ma,mi,sum; 11 int ad,st; 12 bool flag1,flag2; 13 node ... 阅读全文
posted @ 2013-11-02 17:10 Yours1103 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 又是一道线段树区间更新的题; 1 #include 2 #include 3 #include 4 #define ll long long 5 #define maxn 500005 6 using namespace std; 7 ll sum[maxn]; 8 struct tree 9 { 10 int l,r; 11 int ml,mr; 12 int pre,suf; 13 tree *left,*right; 14 } tr[maxn*2]; 15 16 int trcount; 17 18 void build(tree *... 阅读全文
posted @ 2013-11-02 12:05 Yours1103 阅读(238) 评论(0) 推荐(0) 编辑