摘要: 成链的时候 是最坏情况 O(n^2)的复杂度呢! 按照输入的数据 一个一个的插入建树 然后维护左右儿子的个数 (我们规定, 左儿子 小于 父亲 右儿子大于父亲) 往左走 说明存在逆序对 逆序对的个数就是父亲+父亲右儿子的节点数 阅读全文
posted @ 2018-07-22 11:32 过路人1998 阅读(275) 评论(0) 推荐(0) 编辑
摘要: // 根据下标 得到相应块...我感觉..这个就是核心了= =. // vlen = sqrt(1.0 * n); inline int getid(int index) { return (index - 1) / vlen + 1; } void add() { // Todo : 添加一个元素 同时维护块信息 } void sub(int index) { ... 阅读全文
posted @ 2018-07-22 10:25 过路人1998 阅读(104) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include #include using namespace std; typedef long long ll; int intval; // 排序函数什么的 还有排序函数需要用到的变量都放到全局中 否则会出错. ///// 因为排序函数要求 static 表示静态 所以排序函数用到... 阅读全文
posted @ 2018-07-22 10:15 过路人1998 阅读(139) 评论(0) 推荐(0) 编辑
摘要: class TreeArraryTwo{public :const static int cmaxn = 1e3+200;int date[cmaxn][cmaxn];int xsz, ysz;void init(int size_x, int size_y) {xsz = size_x; ysz 阅读全文
posted @ 2018-07-22 08:48 过路人1998 阅读(93) 评论(0) 推荐(0) 编辑