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 -->
链式前向星

链式前向星

链式前向星对于图的存储十分方便,我们可以对一个节点进行访问,遍历所有与他相连的边,从而访问与它临近的所有节点,比如说在bfs版本的spfa实现最短路时,就有很好的应用。

与邻接矩阵、邻接表不同的是,存的是“边”

Read more -->
归并排序 解 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 -->
Site by Baole Zhao | Powered by Hexo | theme PreciousJoy