题目:只允许交换相邻元素的排序,统计将最小交换次数。
分析:分治,逆序数。在合并排序的过程中进行逆序对的求解。
合并A,B两个字串时利用两根指针作为计数;
当B中元素放入新数组时A中所剩元素一定大于B;
每次计数加和即可。
说明:置换群 可以用来计算任意最小交换。。。 (2011-09-20 14:25)
#in...
分类:
其他好文 时间:
2014-09-16 09:17:40
阅读次数:
173
DescriptionIn this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping ...
分类:
其他好文 时间:
2014-09-04 13:08:20
阅读次数:
185
Ultra-QuickSortTime Limit:7000MSMemory Limit:65536KTotal Submissions:39279Accepted:14163DescriptionIn this problem, you have to analyze a particular s...
分类:
其他好文 时间:
2014-08-19 20:29:15
阅读次数:
247
解题报告
题意:
求逆序数。
思路:
线段树离散化处理。
#include
#include
#include
#include
#define LL long long
using namespace std;
LL sum[2001000],num[501000],_hash[501000];
void push_up(int rt)
{
sum[rt]=sum[rt...
分类:
其他好文 时间:
2014-08-11 00:22:01
阅读次数:
255
题目地址:POJ 2299
这题曾经用归并排序做过,线段树加上离散化也可以做。一般线段树的话会超时。
这题的数字最大到10^10次方,显然太大,但是可以利用下标,下标总共只有50w。可以从数字大的开始向树上加点,然后统计下标比它小即在它左边的数的个数。因为每加一个数的时候,比该数大的数已经加完了,这时候坐标在它左边的就是一对逆序数。
但是该题还有一个问题,就是数字重复的问题。这时候可以在排序...
分类:
其他好文 时间:
2014-08-10 15:43:20
阅读次数:
210
Ultra-QuickSort
Time Limit: 7000MS
Memory Limit: 65536K
Total Submissions: 41215
Accepted: 14915
Description
In this problem, you have to analyze a particular sorting a...
分类:
其他好文 时间:
2014-08-08 21:29:06
阅读次数:
301
poj 2299 Ultra-QuickSort(树状数组求逆序数+离散化)...
分类:
其他好文 时间:
2014-08-06 10:30:11
阅读次数:
172
点击打开链接
Ultra-QuickSort
Time Limit: 7000MS
Memory Limit: 65536K
Total Submissions: 40827
Accepted: 14752
Description
In this problem, you have to analyze a partic...
分类:
其他好文 时间:
2014-08-04 21:45:18
阅读次数:
318