avatar
fireworks99
keep hungry keep foolish
归并排序 解 POJ 2299 Quick-Sort

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 sequence is sorted in ascending order. For the input sequence 9 1 0 5 4 ,

Read more -->
归并排序图解版

归并排序过程探索

Read more -->
归并排序

归并排序

归并排序是建立在归并操作上的一种有效的排序算法,该算法是采用分治法(Divide and Conquer)的一个非常典型的应用。将已有序的子序列合并,得到完全有序的序列;即先使每个子序列有序,再使子序列段间有序。若将两个有序表合并成一个有序表,称为二路归并。

Read more -->
POJ 2299 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 sequence is sorted in ascending order. For the input sequence 9 1 0 5 4 ,

Read more -->
POJ 2528 Mayor's posters

Description

The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all places at their whim. The city council has finally decided to build an electoral wall for placing the posters and introduce the following rules:

Read more -->
离散化 线段树 HDU 5124

关于离散化

离散化是什么:一些数字,他们的范围很大(0-1e9),但是个数不算多(1-1e5),并且这些数本身的数字大小不重要,重要的是这些数字之间的相对大小(比如说某个数字是这些数字中的第几小,而与这个数字本身大小没有关系,要的是相对大小)(6 8 9 4 离散化后即为 2 3 4 1)(要理解相对大小的意思)(6在这4个数字中排第二小,那么就把6离散化成2,与数字6本身没有关系, 8,9,4亦是如此)

我个人觉得“离散化”根据其功能明明应该命名为“聚敛化”

Read more -->
线段树 HDU 1556 Color the ball

线段树

擅长处理区间,可以快速的查找某一个节点在若干条线段中出现的次数,时间复杂度为O(logN)。而未优化的空间复杂度为2N,实际应用时一般还要开4N的数组以免越界,因此有时需要离散化让空间压缩。

Read more -->
拓扑排序 HDU 3342

拓扑排序判断各工程先后顺序是否出现矛盾(a -> b, b -> c, c -> a)

BFS在这方面较DFS有些先天优势,统计入队结点数,看是否等于工程数

DFS的vis[]数组改为0, -1, 1三个状态,0代表未访问,-1代表访问完毕,1代表是这一阶段正在访问的 (注意 if(-1) 相当于 if(1) )【坑了自己一阵】

注意n个工程是(0 ~ n - 1 )还是 (1 ~ n)

Read more -->
拓扑排序 UVA 10305

拓扑排序解决工程的先后问题

DFS在这方面较BFS有些先天优势,本身按工程的先后顺序搜索。答案由后向前存入stack

BFS加一个 in[] 数组,保证某一个工程(其前面有许多工程)在可行方案中尽量靠后放。答案由前向后存入vector

Read more -->
SDNUOJ 1169火星人

Description

人类终于登上了火星的土地并且见到了神秘的火星人。人类和火星人都无法理解对方的语言,但是我们的科学家发明了一种用数字交流的方法。这种交流方法是这样的,首先,火星人把一个非常大的数字告诉人类科学家,科学家破解这个数字的含义后,再把一个很小的数字加到这个大数上面,把结果告诉火星人,作为人类的回答。

Read more -->
Site by Baole Zhao | Powered by Hexo | theme PreciousJoy