chen_zhe @ 2018-05-02 21:29:11
#include <iostream>
#include <algorithm>
using namespace std;
struct node
{
int value;
int left,right;
}son[2200000];
int father[2200000],n,m,Max;
void build(int id,int left,int right)
{
son[id].left=left,son[id].right=right;
if (left==right)
{
father[left]=id;
return;
}
build(id<<1,left,(left+right)>>1);
build((id<<1)+1,((left+right)>>1)+1,right);
}
void update_single(int r)
{
if (r==1) return;
int r1=r/2;
int a=son[r1<<1].value;
int b=son[(r1<<1)+1].value;
son[r1].value=a>b?a:b;
update_single(r>>1);
}
void query(int id,int left,int right)
{
if (son[id].left>=left && son[id].right<=right)
{
Max=Max>son[id].value?Max:son[id].value;
return;
}
id=id<<1;
if (left<=son[id].right)
{
if (right<=son[id].right)
query(id,left,right);
else query(id,left,son[id].right);
}
id++;
if (right>=son[id].left)
{
if (left>=son[id].left)
query(id,left,right);
else query(id,son[id].left,right);
}
}
int main()
{
//ios_base::sync_with_stdio(0);
cin >> n >> m;
build(1,1,n);
for (int i=1;i<=n;i++)
{
int a;
cin >> a;
son[father[i]].value=a;
update_single(father[i]);
}
for (int i=1;i<=m;i++)
{
int k,a,b;
cin >> k;
if (k==1)
{
Max=-1<<30;
cin >> a >> b;
if (a>b)
{
int t=a;
a=b;
b=t;
}
query(1,a,b);
cout << Max << endl;
}
else
{
cin >> a >> b;
son[father[a]].value=b;
update_single(father[a]);
}
}
return 0;
}
by Siyuan @ 2018-05-02 21:49:34
chen_zhe大佬开始切毒瘤题了。。。
by Kujolord @ 2018-05-02 21:58:12
vijos上难度7级在chen_zhe大佬眼里算什么东西?
by chen_zhe @ 2018-05-02 22:00:06
总结一句话:我脑抽
by chen_zhe @ 2018-05-02 22:02:30
@全能D囧 我的账号lv8 很久不做题了
by Kujolord @ 2018-05-02 22:04:33
@chen_zhe vijos也是皮得很,A+B被定为难度9
by 硫硫硫化氢_ @ 2018-05-02 22:13:36
@chen_zhe 您还是萌新?!!!
好吧如果您是萌新那我是什么……弱鸡吗……
by XeCtera @ 2018-05-02 22:14:43
@chen_zhe 如果您是萌新那我岂不是都不知道电脑是什么
by 2016gdgzoi471 @ 2018-05-02 22:17:11
@chen_zhe 假!
by Siyuan @ 2018-05-02 22:18:05
by МiсDZ @ 2018-05-02 22:34:30
@chen_zhe 下次应该开小号问,这样只会被怼。。。