线段树是一种强(傻)大(逼)的数据结构,但博主实在是无聊,只好默默的玩一下这种强(傻)大(逼)的数据结构(博主N年前就已经掌握了这种数据结构)。但博主为了共产(工厂)主义事业,终于写下了这个代码(为NOIPPJ的水题奋斗)。
/*************************************************************************
> File Name: \LJF\数据结构\树\线段树\单点更新模板.cpp
> Author: ljf_cnyali
> Mail: ljfcnyali@gmail.com
> Last modifiedz: 2017-02-2 11:49
> Description: This is a large group of God's program information.
************************************************************************/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
using namespace std;
#define REP(i, a, b) for(int i = (a), _end_ = (b);i <= _end_; ++ i)
#define mem(a) memset((a), 0, sizeof(a))
#define str(a) strlen(a)
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
const int maxn = 10000;
int n, m;
int Tree[maxn << 2];
void pushup(int rt) {
Tree[rt] = Tree[rt << 1] + Tree[rt << 1 | 1];
}
void Bulid(int l, int r, int rt) {
if(l == r) {
Tree[rt] = 0;
return;
}
int mid = (l + r) >> 1;
Bulid(lson);
Bulid(rson);
pushup(rt);
}
void update(int pos, int val, int l, int r, int rt) {
if(l == r) {
Tree[rt] += val;
return;
}
int mid = (l + r) >> 1;
if(pos <= mid)
update(pos, val, lson);
else
update(pos, val, rson);
pushup(rt);
}
int query(int L, int R, int l, int r, int rt) {
if(L <= r && r <= R)
return Tree[rt];
int mid = (l + r) >> 1;
int ret = 0;
if(L <= mid)
ret += query(L, R, lson);
if(R > mid)
ret += query(L, R, rson);
return ret;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
return 0;
}