摘要: 原来听到树状数组这名字感觉很难,很高大上。学了一下发现不难。而且很好。 普通的数组修改某个值耗费为O(1),输出和为O(n);而树状数组为O(logn);lowbit(x){ return x&(-x);}返回的是x二进制最后一位1的位置; 有公式:cn=a(n-a^k+1)+.........+a 阅读全文
posted @ 2015-06-07 18:58 sweat123 阅读(255) 评论(0) 推荐(0)
摘要: 1 #include 2 #include 3 using namespace std; 4 struct node 5 { 6 int id; 7 int val; 8 friend bool operatorb.id;15 }16 }17 };1... 阅读全文
posted @ 2015-06-07 16:36 sweat123 阅读(203) 评论(0) 推荐(0)
摘要: 1 #include<stdio.h> 2 #include<queue> 3 using namespace std; 4 5 6 struct node 7 { 8 friend bool operator< (node x,node y) 9 { 10 return x.pre>y.pre;/ 阅读全文
posted @ 2015-06-07 14:04 sweat123 阅读(203) 评论(0) 推荐(0)