一道比较有趣的线段树题目,因为数字不大,而且采取的开平方的操作,所以每个数字最多被开6次平方,再开方也不会变得更小了因为已经变成1了, 也就是说,当一个区间的最大值是1的时候,我们已经没有必要去更改这些区间,尝试加入这种优化后,是否能ac题目呢,答案是可以的.虽然我并不会计算复杂度,
/*
You held me down but I broke free,
I found the love inside of me.
Now I don't need a hero to survive
Cause I already saved my life.
*/
#include
using namespace std;
const int maxn = 1e6+5;
const int INF = 1e9+7;
typedef long long ll;
typedef pair pii;
#define all(a) (a).begin(), (a).end()
#define pb(a) push_back(a)
vector G[maxn];
ll tree[maxn],mx[maxn];ll a[maxn];
#define L (idxn;
for(int i=1;i>a[i];
build(1,1,n);
int m;cin>>m;
while(m--){
int op,l,r;cin>>op>>l>>r;
if(r
关注
打赏