摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2795思路:数组只要开min(h,n)大小就行了。。。线段树最后一层存的是每行的剩余量,然后父节点存当前子树中最大连续空余。View Code 1 #include 2 const int MAXN=200007; 3 using namespace std; 4 int h,w,n; 5 int MAX[MAXN>1;15 Build(l,m,rt>1;25 int ret=(MAX[rt=x)?Query(x,l,m,rtn)h=n;34 Build(1,h,1... 阅读全文
posted @ 2013-04-01 18:45 ihge2k 阅读(219) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1394思路:求最小的逆序数。。。可以暴力,也可以用线段树来做。。。下面是用线段树实现的代码:View Code 1 #include 2 const int MAXN=5007; 3 using namespace std; 4 int sum[MAXN>1;27 if(p>1;37 int ret=0;38 if(Lm)ret+=query(L,R,m+1,r,rt<<1|1);40 return ret;41 }42 43 44 int main(){45 ... 阅读全文
posted @ 2013-04-01 17:17 ihge2k 阅读(197) 评论(0) 推荐(0) 编辑