题很简单:给两个操作1:查找最左边的a个空余块并填满 2:把从第a个开始的连续b个块置空 线段树维护左连续,右连续,最大连续,lazy-tag即可,query函数值得学习 #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> using namespace std; #define maxn 500005 #define lson l,m,rt<<1 #…
题目链接: http://poj.org/problem?id=3667 题意:第一行输入 n, m表示有 n 间房间(连成一排的), 接下来有 m 行输入, 对于接下来的 m 行输入: 1 x : 询问是否有长度为 x 的连号空房, 若有, 住进最左边并输出对应编号: 2 x y : 将区间 [x, x + y - 1] 的房间清空: 思路: 并查集区间合并&区间查询 下面一段题解摘自: http://www.cnblogs.com/scau20110726/archive/2013/05/0…
poj3667 HotelTime Limit: 3000MS Memory Limit: 65536KTotal Submissions: 18925 Accepted: 8242Description The cows are journeying north to Thunder Bay in Canada to gain cultural enrichment and enjoy a vacation on the sunny shores of Lake Superior. Bessi…
P2894 [USACO08FEB]酒店Hotel 题目描述 The cows are journeying north to Thunder Bay in Canada to gain cultural enrichment and enjoy a vacation on the sunny shores of Lake Superior. Bessie, ever the competent travel agent, has named the Bullmoose Hotel on fam…
两道题都是线段树的区间合并 lsum, rsum分别表示左/右端点 开始向右/左 符合条件的元素的最长连续长度 sum表示这个区间的符合条件的元素的最长连续长度 所以pushUp可写: void pushUp(int root, int l, int r) { ; , lenl = len - lenr; lsum[root] = lsum[lson]; rsum[root] = rsum[rson]; if (lsum[root] == lenl) lsum[root] += lsum[rso…
//Accepted 3728 KB 1079 ms //线段树 区间合并 #include <cstdio> #include <cstring> #include <iostream> #include <queue> #include <cmath> #include <algorithm> using namespace std; /** * This is a documentation comment block * 如果…
题目链接:传送门 参考文章:传送门 思路:线段树区间合并问题,每次查询到满足线段树的区间最左值,然后更新线段树. #include<iostream> #include<cstdio> #include<cstring> using namespace std; ; ],rsum[maxn<<],msum[maxn<<],cover[maxn<<]; void build(int x,int l,int r) { lsum[x]=rs…
Hotel 转载自:http://www.cnblogs.com/scau20110726/archive/2013/05/07/3065418.html [题目链接]Hotel [题目类型]线段树 区间合并 &题意: 有一个线段,从1到n,下面m个操作,操作分两个类型,以1开头的是查询操作,以2开头的是更新操作 1 w 表示在总区间内查询一个长度为w的可用区间,并且要最靠左,能找到的话返回这个区间的左端点并占用了这个区间,找不到返回0 好像n=10 , 1 3 查到的最左的长度为3的可用区间就…
点我看题目链接 题意 : 很多花盆组成的圆圈,每个花盆都有一个值,给你两个数a,b代表a位置原来的数换成b,然后让你从圈里找出连续的各花盆之和,要求最大的. 思路 :这个题比较那啥,差不多可以用DP的思想来解决这个问题,你在某个地方将这个环断开,因为线段树无法建成环形的.然后再去找那个最大值.将这个序列分成两部分,先求左边的最大连续和a,再求右边连续和b,但是由于他们中间相连的那部分,就是左部分的最右边的连续最大和x加上右部分的最左边的连续最大和y加起来可能比ab都大,但分开的话可能并没有a或b…
LCIS Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6069    Accepted Submission(s): 2635 Problem Description Given n integers.You have two operations:U A B: replace the Ath number by B. (index…