>Description
在N(1<=N<=100000)个数A1…An组成的序列上进行M(1<=M<=100000)次操作,操作有两种:
(1)1 x y:表示修改A[x]为y;
(1)2 x y:询问x到y之间的最大值。
>Input
第一行输入N(1<=N<=100000),表示序列的长度,接下来N行输入原始序列;接下来一行输入M(1<=M<=100000)表示操作的次数,接下来M行,每行为1 x y或2 x y
>Output
对于每个操作(2)输出对应的答案。
>Sample Input
5
1
2
3
4
5
3
2 1 4
1 3 5
2 2 4
>Sample Output
4
5
保证序列中的所有的数都在longint范围内
>解题思路
线段树模板。
>代码
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,a[100005],z,x[100005],y[100005],t[400005],sum;
void lil(int l,int r,int s) //区间起始,区间终止,线段树中的编号
{
if(l==r)
{
t[s]=a[l];
return;
}
int mid=(l+r)/2;
lil(l,mid,s