随笔分类 - ACM-数据结构-树状数组
摘要:Different Integers 具体见代码: 1 #include <bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const int maxn=1e5+10; 5 const int mod=1e9+7; 6
阅读全文
摘要:分析:我们可以逆向考虑(因为正向的话由于第一位的逆序对数一定是0,算不出什么),对于第i个数,它使逆序对的数量增加了temp=num[i]-num[i-1],即区间【1,i-1】内比这个数大的有temp个,即它在i个数中从小到大排在(i-temp)个,那么找到这个数即可。 对于答案序列来讲,他是一个
阅读全文
摘要:K Integers 参考博客:https://blog.csdn.net/Q755100802/article/details/103664555 【题意】 给定一个1到n的排列,可以交换相邻的两个元素。 现在定义一个函数f(x),表示在原排列中,通过交换操作,形成一个1,2,3....x的排列的
阅读全文
摘要:P1908 逆序对 离散化+树状数组:AC_Code 1 #include <bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const int maxn=500010; 5 6 int a[maxn],tree[max
阅读全文
摘要:个人觉得非常棒的博客:https://www.cnblogs.com/xenny/p/9739600.html 第一类:单点更新,区间查询 例题:http://acm.hdu.edu.cn/showproblem.php?pid=1166 AC代码: 1 /* */ 2 # include <ios
阅读全文