#include<stdio.h>
#include<string.h>
#include<string>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<stdlib.h>
#include<time.h>
#include <iomanip>
#define lowbit(x) (x&(-x))
#define inf 0x3f3f3f3f
#define fill(x,y) memset(x,y,sizeof(x))
#define fup(i,x,y) for(int i=(x);i<=(y);i++)
#define fdn(i,x,y) for(int i=(x);i>=(y);i--)
#define pf printf
#define sf scanf
#define sp(x) setprecision(x)
#define sd(n) scanf("%d",&n)
#define sdd(n,m) scanf("%d%d",&n,&m)
#define sddd(n,m,k) scanf("%d%d%d",&n,&m,&k)
#define sld(n) scanf("%lld",&n)
#define sldd(n,m) scanf("%lld%lld",&n,&m)
#define slddd(n,m,k) scanf("%lld%lld%lld",&n,&m,&k)
#define sf(n) scanf("%lf",&n)
#define sff(n,m) scanf("%lf%lf",&n,&m)
#define sfff(n,m,k) scanf("%lf%lf%lf",&n,&m,&k)
#define pf(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define N 1000005
#define M 400009
#define mod 1000000
#define pi acos(-1)
//cout.setf(ios::fixed);
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
using namespace std;
typedef long long ll;
typedef double db;
const long long linf = 0x3f3f3f3f3f3f3f3fll;
inline int scan(int &n)
{
int res=0,ch,flag=0;
if((ch=getchar())=='-')flag=1;
else if(ch>='0' && ch<='9')res=ch-'0';
while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-'0';
n= flag ? -res : res;
}
int t[3*N],a[N];
void build(int r,int st,int ed)
{
if(st==ed) t[r]=a[st];
else
{
int mid=(st+ed)>>1;
build(r<<1,st,mid);
build(r<<1|1,mid+1,ed);
t[r]=min(t[r<<1],t[r<<1|1]);
}
}
void update(int r,int st,int ed,int k,int b)
{
if(st==ed)
{
t[r]=b;
return ;
}
int mid=(st+ed)>>1;
if(k>mid) update(r<<1|1,mid+1,ed,k,b);
else update(r<<1,st,mid,k,b);
t[r]=min(t[r<<1],t[r<<1|1]);
}
int findm(int r,int st,int ed,int x,int y)
{
if(st>y||ed<x) return inf;
if(st>=x&&ed<=y) return t[r];
int mid=(st+ed)>>1;
return min(findm(r<<1,st,mid,x,y),findm(r<<1|1,mid+1,ed,x,y));
}
int main()
{
int n;
sd(n);
fup(i,1,n)
sd(a[i]);
build(1,1,n);
int q;
sd(q);
while(q--)
{
int f,x,y;
sddd(f,x,y);
if(f)
{
update(1,1,n,x,y);
}
else
{
pf(findm(1,1,n,x,y));
}
}
return 0;
}
线段树点更新板子HihoCoder - 1077
最新推荐文章于 2020-04-01 20:08:52 发布