LCIS hdu3308 (线段树 区间合并)】的更多相关文章

题意: 有两种操作  一种是单点改为b  一种是给出区间ab  区间ab的最大上升子序列个数.. 线段树目前学了三种  第一种单点操作很简单   第二种区域操作加上懒惰标记即可 现在这种 为区间合并....多看就好了 #include<bits/stdc++.h> using namespace std; #define N 100010 #define lson L,m,pos<<1 #define rson m+1,R,pos<<1|1 #define mid m=…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3308 ,简单的线段树区间合并. 线段树的区间合并:一般是要求求最长连续区间,在PushUp()函数中实现区间合并操作. 解法: 由于对于一个区间的最长序列来说,最优解要么完全在左半序列,要么完全在右半序列,要么跨越中间点.所以可以构造线段树,维护结点区间的三个元素:最长上升前缀len[].l,最长上升后缀len[].r,最长上升序列len[].m.所以对于一个区间来说,有这样两种情况: 1. 左儿子…
Problem Description Given n integers. You have two operations: U A B: replace the Ath number by B. (index counting from 0) Q A B: output the length of the longest consecutive increasing subsequence (LCIS) in [a, b]. 题目大意就是给你一个数列,求区间内的最长连续子序列.以及对某一个点的…
LCIS Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5912    Accepted Submission(s): 2563 Problem Description Given n integers. You have two operations: U A B: replace the Ath number by B. (ind…
题目链接:http://acm.hdu.edu.cn/showproblem.php? pid=3308 LCIS Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5792    Accepted Submission(s): 2513 Problem Description Given n integers. You have two…
更新一个点: 求某个区间的最长连续上升序列: 链接:http://acm.hdu.edu.cn/showproblem.php?pid=3308 #include <cstdio> #include <algorithm> using namespace std; #define maxn 100009 #define mid int m=(l+r)>>1 ], rsum[maxn<<], msum[maxn<<], n, m, p, v, a,…
给n个数字 U表示第A个数改为B.A是从0开始. Q输出最大的递增序列个数. 考虑左边,右边,和最大的. #include<stdio.h> #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 #define maxn 100010 ],rsum[maxn<<],msum[maxn<<]; int num[maxn]; int max(int x,int y) { return x>y?x:y…
LCIS Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8337    Accepted Submission(s): 3566 Problem Description Given n integers.You have two operations:U A B: replace the Ath number by B. (index…
LCIS HDU - 3308 Given n integers. You have two operations: U A B: replace the Ath number by B. (index counting from 0) Q A B: output the length of the longest consecutive increasing subsequence (LCIS) in [a, b].  InputT in the first line, indicating…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3308 题目很好懂,就是单点更新,然后求区间的最长上升子序列. 线段树区间合并问题,注意合并的条件是a[mid + 1] > a[mid],写的细心点就好了. #include <iostream> #include <cstring> #include <cstdio> using namespace std; ; struct SegTree { int l , r…