-
树状数组
摘要:hdu 4267 A Simple Problem with Integers http://acm.hdu.edu.cn/showproblem.php?pid=4267多个树状数组,区间跟新,单点询问,转化为单点更新,求和View Code 1 #include <cstdio> 2 #include <cstring> 3 using namespace std; 4 5 const int N=50010; 6 int c[11][10][N]; 7 int a[N]; 8 int lowbit(int x) 9 {10 return x&(-x);11
阅读全文
-
HDU 3015 Disharmony Trees
摘要:树状数组View Code 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 using namespace std; 5 6 typedef __int64 LL; 7 const int N=100010; 8 struct node 9 {10 int nx,nh,x,h;11 bool operator < (const node &a)const12 {13 return nh<a.nh;14 }15 }a[N];16 LL c1[N];17 in
阅读全文
-
HDU 4217 Data Structure?
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4217View Code 1 #include <cstdio> 2 #include <cstring> 3 using namespace std; 4 5 typedef __int64 LL; 6 const int N=270000; 7 int c[N]; 8 int lowbit(int x) 9 {10 return x&(-x);11 }12 void add(int x,int p,int maxn)13 {14 for(int i=p;i<=maxn
阅读全文
-
HDU 3333 Turing Tree
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3333树状数组+离散化+离线算法读入所有区间,按右端点排序,每加入一个数时,如果已经加过,就在该数原来位置减去它,在新位置加上它View Code 1 #include <cstdio> 2 #include <algorithm> 3 using namespace std; 4 5 typedef __int64 LL; 6 const int N=30010,Q=100010; 7 int a[N],n,vis[N]; 8 int dz[N],nd; 9 LL c[N];10 s
阅读全文
-
HDU 2852 KiKi's K-Number
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2852View Code 1 //2852 2 #include <cstdio> 3 #include <cstring> 4 using namespace std; 5 6 const int N=100010,maxn=100000; 7 int c[N]; 8 int lowbit(int x) 9 {10 return x&(-x);11 }12 int sum(int x)13 {14 int s=0;15 for(int i=x;i>0;i-=lowbit
阅读全文
-
HDU 2227 Find the nondecreasing subsequences
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2227离散化+树状数组View Code 1 //2227 2 #include <cstdio> 3 #include <cstring> 4 #include <algorithm> 5 using namespace std; 6 7 const int N=100010,maxn=100000,md=1000000007; 8 int val[N],a[N]; 9 __int64 c[N];10 int lowbit(int x)11 {12 return x&am
阅读全文
-
HDU 3743 Frosh Week
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3743离散化+树状数组View Code 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 using namespace std; 5 6 const int N=1000100,maxn=1000000; 7 int val[N],a[N],c[N]; 8 int lowbit(int x) 9 {10 return x&(-x);11 }12 int bfind(int x,in
阅读全文
-
HDU 2838 Cow Sorting
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2838View Code 1 #include <cstdio> 2 #include <cstring> 3 using namespace std; 4 5 const int N=100100,maxn=100000; 6 int ccnt[N]; 7 __int64 csum[N]; 8 int lowbit(int x) 9 {10 return x&(x^(x-1));11 }12 int main()13 {14 int n,x;15 while (~scanf(
阅读全文
-
HDU 2642 Stars
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2642View Code 1 #include <cstdio> 2 #include <cstring> 3 using namespace std; 4 5 const int N=1010,maxn=1001;; 6 char flag[N][N]; 7 int c[N][N]; 8 int lowbit(int x) 9 {10 return x&(-x);11 }12 int sum(int x,int y)13 {14 int cnt=0;15 for(int i=
阅读全文
|