摘要:
#include<cstdio> #include<cstdlib> #include<algorithm> #include<ctime> using namespace std; inline int random(int n); int main(){ freopen("data.in","w 阅读全文
posted @ 2021-10-17 23:52
蔚蓝-星辰
阅读(236)
评论(0)
推荐(0)
摘要:
考虑使序列P最终升序 1.若只能交换相邻元素,由于每一次有效交换,都会使序列的逆序对数目减少1,故最小交换次数即为序列P的逆序对数目。可用树状数组求解逆序对数目。 2.若可以任意交换序列中的元素,可贪心的考虑。每一次有效交换都至少使一个数到达其最终所在的位置。故遍历i从1到n,如果i在其最终的位置, 阅读全文
posted @ 2021-10-17 23:29
蔚蓝-星辰
阅读(157)
评论(0)
推荐(0)

浙公网安备 33010602011771号