果枫-国峰

随笔分类 -  线段树

hdu 1166
摘要:题意:中文题,省。解法:线段树。注意:输入,输出最后用scanf(),printf(),其他的可能超时。ac代码:View Code //线段树,节点更新,区间求和#include<iostream>#include<string>using namespace std;const int M=50000+10;//最大区间int num[M];//记录每一个营的人数struct treestruct{ int left;//左区间 int right;//右区间 int sum;//区间求和}node[M*3];//节点数大约是最大区间的3倍int build(int 阅读全文

posted @ 2012-09-10 17:01 果枫-国峰 阅读(123) 评论(0) 推荐(0)

hdu 1556
摘要:View Code #include<iostream>using namespace std;const int M=100000+9;struct treenode{ int left;//左区间 int right;//右区间 int sum; //区间之和}node[M*3];//节点数大约是最大区间的3被void build(int low,int top,int index)//功能:建树{ node[index].left=low; node[index].right=top; node[index].sum=0; if(low==top... 阅读全文

posted @ 2012-09-10 15:41 果枫-国峰 阅读(179) 评论(0) 推荐(0)

导航