
排序
SCUT_Pein
这个作者很懒,什么都没留下…
展开
-
POJ1094--Sorting It All Out--拓补排序
Description An ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from smallest to largest. For example, the sorted sequence原创 2013-02-10 23:07:45 · 469 阅读 · 0 评论 -
归并排序求逆序数
#include using namespace std; int A[500008],AA[500008]; long long int sum; void merge_sort(int *A,int x,int y,int *T) { if(y-x>=1) { int m=x+(y-x)/2; int p=x,q=m+1,i=x; merge_sort(A,x,m,T);原创 2014-04-09 18:21:27 · 543 阅读 · 0 评论 -
归并排序总结
本文主要摘自刘汝佳的《算法竞赛入门经典》。我只是加上我看时的一些感悟。 按照分治三步法,对归并排序算法介绍如下: 划分问题:把序列分成元素个数尽量相等的两半。 递归问题:把两半元素分别排序 合并问题:把两个有序表合并成一个。。(这里需要排序。但是因为两半都是从小到大排序好的,所以我们每次都拿两边最小的元素进行比较,拿小的放左边。用了的元素删掉。接着继续找) 接下来,先亮上刘汝佳的代码。原创 2013-02-09 02:35:45 · 667 阅读 · 0 评论 -
POJ2299--归并排序--Ultra-QuickSort
Description In this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence elements until the seque原创 2013-03-20 01:56:11 · 721 阅读 · 0 评论 -
POJ3687--Labeling Balls
Description Windy has N balls of distinct weights from 1 unit to N units. Now he tries to label them with 1 to N in such a way that: No two balls share the same label.The labeling satisfies原创 2013-04-29 12:49:17 · 791 阅读 · 0 评论 -
POJ1270--Following Orders
Description Order is an important concept in mathematics and in computer science. For example, Zorn's Lemma states: ``a partially ordered set in which every chain has an upper bound contains a maxima原创 2013-04-28 09:47:32 · 814 阅读 · 0 评论 -
POJ2367--Genealogical tree
Description The system of Martians' blood relations is confusing enough. Actually, Martians bud when they want and where they want. They gather together in different groups, so that a Martian can hav原创 2013-04-28 16:54:01 · 730 阅读 · 0 评论 -
POJ2585--Window Pains
Description Boudreaux likes to multitask, especially when it comes to using his computer. Never satisfied with just running one application at a time, he usually runs nine applications, each in its o原创 2013-04-28 16:02:01 · 1021 阅读 · 0 评论 -
Segment
Description They are N segments in x-axis, each segment has a start point X, a end point Y, so it can express as [X, Y]. Now you should select two segments, they have the longest overlap lengt原创 2013-03-11 15:39:32 · 940 阅读 · 0 评论 -
CF240 DIV1 C--归并排序求逆序
Mashmokh and Reverse Operation time limit per test 4 seconds memory limit per test 512 megabytes input standard input output standard output Mashmokh's boss, Bimokh, did原创 2014-04-10 16:23:43 · 832 阅读 · 0 评论