题意:两种操作,Q L R查询L - R 的最长连续上升子序列长度,U pos val 单点修改值 #include <bits/stdc++.h> #define N 100005 using namespace std; ],pre[N<<],suf[N<<],arr[N];维护区间lcs长度,以左端点为起点的lcs长度,以右端点为终点的lcs长度,这么做是为了处理区间合并后区间总lcs值的更新 void pushup(int l,int r,int rt) { ;…
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…
HDU1754 I Hate It Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Description 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少. 这让很多学生很反感. 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问.当然,老师有时候需要更新某位同学的成绩.   Input 本题目包含多组测试,请处理到文件结束.…
题意: T个测试数据 n个数 q个查询 n个数 ( 下标从0开始) Q u v 查询 [u, v ] 区间最长连续上升子序列 U u v 把u位置改成v #include<iostream> #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; #define N 101010 #define L(x) (x<<1) #define R(x) (…
原题链接 http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1809 Description Bobo has a balanced parenthesis sequence P=p1 p2…pn of length n and q questions. The i-th question is whether P remains balanced after pai and pbi  swapped. Note that questions ar…
思想 : 1 优化:题意是覆盖点,将区间看成 (l,r)转化为( l-1,r) 覆盖区间 2 核心:dp[i]  覆盖从1到i区间的最小花费 dp[a[i].r]=min (dp[k])+a[i]s;  l-1=<k<=r-1 (可我总是想着从后到前,从 前到后反而更好理解) 3  离散区间---使用线段树求区间最值  时间复杂度O(nlogn) ps (一定忍住不看别人的代码,继续加油) #include <bits/stdc++.h> #define lson l,m,rt*2…
题目连接 题意: 一条长为N的铜链子,每个结点的价值为1.有两种修改,l,r,z; z=2:表示把[l,r]区间内链子改为银质,价值为2. z=3:表示把[l,r]区间内链子改为金质,价值为3. 思路: 线段树,区间重设,求和. #include<cstdio> #include<cstring> using namespace std; const int maxn=100000+10; struct node { int l; int r; int v;//标记该区间内的链条的…
<题目链接> 题意描述: 给你一个有0--n-1数字组成的序列,然后进行这样的操作,每次将最前面一个元素放到最后面去会得到一个序列,那么这样就形成了n个序列,那么每个序列都有一个逆序数,找出其中最小的一个输出! 解题分析: 先利用线段树求出初始序列的逆序数,这里有一个非常巧妙的地方,由于比a[i]大的数是离散且连续的,所以可以用线段树来实现(与线段树节点的区间特性符合). #include <bits/stdc++.h> using namespace std; #define L…
https://nanti.jisuanke.com/t/30996 线段树维护区间最小值,查询的时候优先向左走,如果左边已经找到了,就不用再往右了. 一个房间装满则把权值标记为INF,模拟一遍,注意考虑一个月内装满多个房间和装满所有房间后不用再购买的情况. 代码: #include <iostream> #include <cstdio> #include <algorithm> const int maxn = 100005; const int INF = 0x3…
题目大意:给n个数,两种操作1:U  a b   更新第a个为b (从0开始)2: Q    a ,b  查询 a,b之间LCIS(最长连续递增子序列)的长度. Sample Input110 107 7 3 3 5 9 9 8 1 8Q 6 6U 3 4Q 0 1Q 0 5Q 4 7Q 3 5Q 0 2Q 4 6U 6 10Q 0 9Sample Output 11423125 #include <stdio.h> #include <stdlib.h> #include <…