文章分类 -  acm数据结构-树状数组

hdu4638 1-n的一个全排列,q个询问,对于每个询问区间有多少个连续区间 : 技巧/离线/树状数组
摘要:随机开了场多校,题目挺好玩题意化简下来就是比如有5 3 4 6 10 11,那么2-6里面有三个连续区间假设一个区间都是独立的,就是最多有l-r+1个连续区间,然后我们要做的就是减去重复的我们离线从左到右扫描原数组,只要a[i]-1出现在前面,那么就在这个位置+1,表示当前i这个不算独立,同理a[i... 阅读全文

posted @ 2015-05-09 04:00 xiao_xin 阅读(427) 评论(0) 推荐(0)

CodeForces 314C Sereja and Subsequences :找出序列种所有不下降子序列,求出所有子序列乘积和 :技巧/树状数组
摘要:树状数组数组里面记录的值是当前以a[i]结尾的乘积和=比如当前到i的a[i],查询1-a[i]的所有值和,乘以(a[i]+1)就是当前以a[i]为结尾的乘积和=这样出现了重复计算的情况,只要减去上一次a[i]结尾的乘积和即可 1 #include 2 #include 3 #include 4 us... 阅读全文

posted @ 2015-03-27 16:54 xiao_xin 阅读(349) 评论(0) 推荐(0)

hdu2852(2009多校第四场) 树状数组求区间第k大的数 两种方法
摘要:二分查找n*logn*logn比较容易理解 1 #include 2 #include 3 #include 4 #define maxx 100005 5 using namespace std; 6 int vis[100010],c[100010],k; 7 int sum(int x) 8 ... 阅读全文

posted @ 2014-12-15 22:20 xiao_xin 阅读(287) 评论(0) 推荐(0)

hdu5032 点和查询分别按极角排序 离线做+树状数组
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 struct jie{ 6 double k; 7 int x,v; 8 }dian[1000005],xian[100005]; 9 long long c[100... 阅读全文

posted @ 2014-09-26 18:05 xiao_xin 阅读(123) 评论(0) 推荐(0)

hdu4991 长为m的上升子序列个数(stl离散化+m个树状数组加速实现dp)
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 int n,c[305][10005],a[10005],b[10005]; 6 int lowbit(int x) 7 { 8 return x&(-x); 9 }10 i... 阅读全文

posted @ 2014-09-09 19:44 xiao_xin 阅读(158) 评论(0) 推荐(0)

hdu1166 树状数组
摘要:1 #include 2 int n,c[1000005]; 3 int lowbit(int x) 4 { 5 return(x&-x); 6 } 7 void add(int x,int d) 8 { 9 while (x0)1... 阅读全文

posted @ 2014-07-16 17:30 xiao_xin 阅读(86) 评论(0) 推荐(0)

hdu2227 树状数组
摘要:1 #include 2 #include 3 #define MOD 1000000007 4 __int64 ans[100005],c[100005]; 5 int a[100005],wei[100005],n; 6 void sort(int l,int r) 7 { 8 int... 阅读全文

posted @ 2014-07-16 16:05 xiao_xin 阅读(112) 评论(0) 推荐(0)

导航