摘要: #include<iostream>#include<fstream>usingnamespacestd;structe{intl,r,cnt,cntl,cntr;intstate;};e tree[48001];intn,m;voidbuild(ints,intt,intp){inti,j,k;tree[p].l=s;tree[p].r=t;tree[p].state=-1;tree[p].cnt=tree[p].cntl=tree[p].cntr=t-s+1;if(s==t) return;else{k=(s+t)>>1;build(s,k,2*p);b 阅读全文
posted @ 2012-07-24 12:56 何解一直犯相同错误? 阅读(230) 评论(0) 推荐(0) 编辑
摘要: 题意:一个hotel,有n间连续的房间,现在有m组操作:type 1: '1, a, b': 第a个房间起的b个房间有旅客入住。type 2:'2, a, b': 第a个房间起的b个房间的旅客离开。type 3: '3': 问最长的连续空房间有多少间。思路:线段树。这道题很好的利用线段树递归的性质,加深了对线段树递归的理解。复习了一下延迟的操作,学会了与延迟操作相反的操作,即利用递归,在递归回来的时候,由于左右子结点性质的改变,即时对父结点信息进行相应的更改,这个要注意。源代码:(944K 3282MS)#include<iostream& 阅读全文
posted @ 2012-07-24 12:56 何解一直犯相同错误? 阅读(180) 评论(0) 推荐(0) 编辑
摘要: Area of Simple PolygonsTime Limit:1000MSMemory Limit:65536KTotal Submissions:2404Accepted:1207DescriptionThere are N, 1 <= N <= 1,000 rectangles in the 2-D xy-plane. The four sides of a rectangle are horizontal or vertical line segments. Rectangles are defined by their lower-left and upper-rig 阅读全文
posted @ 2012-07-24 01:08 何解一直犯相同错误? 阅读(189) 评论(0) 推荐(0) 编辑