目录
线段树(具备基本功能:区间查询,区间修改,单点查询,单点修改)
线段树(具备基本功能:区间查询,区间修改,单点查询,单点修改)
#include<pch.h>
#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>
#include <queue>
#include <map>
#include <algorithm>
#include <stack>
#include <iomanip>
#include <cstring>
#include <cmath>
#define DETERMINATION main
#pragma GCC optimize(2)
#pragma warning(disable:4996)
#define lldin(a) scanf("%lld", &a)
#define println(a) printf("%lld\n", a)
#define print(a) printf("%lld ", a)
#define reset(a, b) memset(a, b, sizeof(a))
#define debug cout<<"procedures above are available"<<endl;
#define BigInteger __int128
using namespace std;
const int INF = 2e9 + 2;
const double PI = acos(-1);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int mod = 1e9 + 7;
//template<typename T>
//inline BigInteger nextBigInteger()
//{
// BigInteger tmp = 0, si = 1;char c; c = getchar();
// while (!isdigit(c))
//{if (c == '-')si = -1;c = getchar();}
// while (isdigit(c))
// {tmp = tmp * 10 + c - '0';c = getchar();}
// return si * tmp;
//}
//std::ostream& operator<<(std::ostream& os, __int128 T)
//{
// if (T<0) os<<"-";if (T>=10 ) os<<T/10;if (T<=-10) os<<(-(T/10));
// return os<<( (int) (T%10) >0 ? (int) (T%10) : -(int) (T%10) ) ;
//}
//void output(BigInteger x)
//{
// if (x < 0)
// {x = -x;putchar('-');}
// if (x > 9) output(x / 10);
// putchar(x % 10 + '0');
// }
/**Maintain your determination.Nobody knows the magnificent landscape
at his destination before the arrival with stumble.**/
/**Last Remote**/
struct node
{
ll left, right, value;
ll laziness;
}nodes[599999];
ll arr[599999];
void construction(ll current,ll left, ll right)
{
nodes[current].left = left, nodes[current].right = right;
if (left == right)
{
nodes[current].value = arr[left];
return ;
}
else
{
ll mid = (left + right) >> 1;
construction(2 * current, left, mid);
construction(2 * current + 1, mid + 1, right);
nodes[current].value = nodes[2 * current].value + nodes[2 * current + 1].value;
}
}
void LazyDown(ll current)
{
nodes[2 * current].laziness+= nodes[current].laziness;
nodes[2 * current + 1].laziness += nodes[current].laziness;
nodes[2 * current].value += (nodes[2 * current].right - nodes[2 * current].left + 1)*nodes[current].laziness;
nodes[2 * current + 1].value += (nodes[2 * current + 1].right - nodes[2 * current + 1].left + 1)*nodes[current].laziness;
nodes[current].laziness = 0;
}
ll investigation(ll current, ll lower, ll upper)
{
if (nodes[current].left >= lower && nodes[current].right <= upper)
{
//cout << nodes[current].value << endl;
return nodes[current].value;
}
else
{
if (nodes[current].laziness