2013年7月28日
摘要: 树状数组求逆序数,先排个序,从大到小往插,计算在他的前面有几个比他大,就是他的逆序数。(PS:最近对数量越来越不敏感了,老在这上面错。多做题,不能断啊) 1 #include 2 #include 3 #include 4 using namespace std; 5 typedef long long i64; 6 struct po 7 { 8 int num,ord; 9 } p[500050];10 int a[500050];11 template12 struct BIT {13 vector a;14 void init(int n) {15 ... 阅读全文
posted @ 2013-07-28 22:00 Ac_国士无双 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 题目大意很简单,按照命令连接节点,findset函数写的时候费了点劲儿,要注意那个累加距离值。其实因为刚开始学,还是对并查集的查询和连接不是很熟悉,多推几次就好了。 1 #include 2 #include 3 #include 4 using namespace std; 5 int set[20010],p[20010]; 6 int findset(int x) 7 { 8 int ans; 9 if(set[x]==x)10 return x;11 else12 {13 ans=findset(set[x]);14 ... 阅读全文
posted @ 2013-07-28 20:48 Ac_国士无双 阅读(286) 评论(0) 推荐(0) 编辑