HDU4614【线段树。】】的更多相关文章

Alice is so popular that she can receive many flowers everyday. She has N vases numbered from 0 to N-1. When she receive some flowers, she will try to put them in the vases, one flower in one vase. She randomly choose the vase A and try to put a flow…
题目大意:有n个花瓶,每个花瓶中只能放一朵花.两种操作,一种是从A开始放F朵花,如果有的花瓶中已经有花则跳过这个花瓶,往下一个花瓶放:第二种是将区间[A,B]之间花瓶中的花清空.如果是第一种操作,输出这次放的花的左右端点:如果是第二种操作,输出这次总共清理出了多少支花. 题目分析:建立线段树,节点维护在相应的区间中,没有放入花的花瓶数目.有三种操作:一.查询某个区间中第k个没有插入花的花瓶位置:二.更新区间,使区间全部插入花:三.更新区间,使区间中的花瓶全部清空: 代码如下: # include…
果然看了理解了一下大牛的代码然后自己敲结果果然有不少错误 回复说,线段树做为一种数据结构,最好以一种风格过一题裸的然后作为自己的模板.. 二分写的也很恶心哪 还有题目稍复杂一点的注定得推敲各种公式,不光DP注意边界那样令自己恶心,就是这些公式+1,-1结果都是差之千里,或者自己根本调试不出来. 思路很重要,模板也比较重要,线段树裸敲的话容易出错,比树状数组出错几率大的多. #include <cstdio> #include <cstdlib> #include <cstri…
分析:感觉一看就是二分+线段树,没啥好想的,唯一注意,当开始摆花时,注意和最多能放的比大小 #include<iostream> #include<cmath> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; ; ],lz[N<<]; void build(int rt,int l,int r){ lz[rt]=-; ;return…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4614 线段树保存区间是否被覆盖以及区间的和即可,在询问的时候在线段树上二分查找就可以了...代码写得比较挫>< //STATUS:C++_AC_359MS_1728KB #include <functional> #include <algorithm> #include <iostream> //#include <ext/rope> #inclu…
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4614 题意:给定一个区间[0,N-1],初始时每个位置上的数字都是0,可以对其进行以下两种操作: 1.在位置A开始寻找F(如果没有这么多,则有多少个就找多少个)个数值为0的位置,把位置上的数修改为1,并返回第一个和最后一个修改的位置 2.查询区间[a,b]内1的个数,并把区间[a,b]每个位置上的数修改为0 线段树功能:区间更替,区间求和. 分析:sum[rt]表示区间0的个数,二分找出0~L的nu…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4614 题意: 给你N个花瓶,编号是0  到 N - 1 ,初始状态花瓶是空的,每个花瓶最多插一朵花. 然后有2个操作. 操作1,a b c ,往在a位置后面(包括a)插b朵花,输出插入的首位置和末位置. 操作2,a b ,输出区间[a , b ]范围内的花的数量,然后全部清空. 很显然这是一道线段树.区间更新,区间求和, 操作2,很显然就是线段树的区间求和,求出[a , b]范围内的花朵的数量,区间…
Alice is so popular that she can receive many flowers everyday. She has N vases numbered from 0 to N-1. When she receive some flowers, she will try to put them in the vases, one flower in one vase. She randomly choose the vase A and try to put a flow…
Alice is so popular that she can receive many flowers everyday. She has N vases numbered from 0 to N-1. When she receive some flowers, she will try to put them in the vases, one flower in one vase. She randomly choose the vase A and try to put a flow…
http://acm.hdu.edu.cn/showproblem.php?pid=4614 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Problem Description Alice is so popular that she can receive many flowers everyday. She has N vases numbered from 0 to…