-
Notifications
You must be signed in to change notification settings - Fork 2
/
BIT-2D.cpp
66 lines (59 loc) · 1003 Bytes
/
BIT-2D.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
ID: mfs6174
PROG: BIT
LANG: C++
*/
#include<iostream>
#include<fstream>
#include<string>
#include<sstream>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
//ifstream inf("ti.in");
//ofstream ouf("ti.out");
//freopen("ti.i","r",stdin);
const int maxlongint=2147483647;
#define MAXN 1000
int shu[MAXN],f[MAXN];
int n;
//注意up中的n表示数组最大范围,如果离散化就是数字数,在线算法不方便离散化就是数字最大范围,灵活处理
//注意从1开始,如果有0号数组,可以每个加1表示
inline int lowbit(int x)
{
return x&(x^(x-1));
}
void upc(int x,int y,int d,int n,int m)
{
while (x<=n)
{
int yy=y;
while (yy<=m)
{
f[x][yy]+=d;
yy+=lowbit(yy);
}
x+=lowbit(x);
}
}
int downs(int x,int y)
{
int s=0;
while (x>0)
{
int yy=y;
while (yy>0)
{
s+=f[x][yy];
yy-=lowbit(yy);
}
x-=lowbit(x);
}
return s;
}
int main()
{
return 0;
}