这道题目主要是排序,刚开始简单写了一个代码,发现最后一个测试数据。发现超时了,sort排序用的是快排。快排平均是O(NlogN),最坏是O(N*N)。输入数据是10^5级的,最坏的情况会超过10^10,会超时。所以刚开始想用其他排序方法sort()---排序stable_sort---稳定排序hea...
分类:
其他好文 时间:
2014-10-10 00:17:03
阅读次数:
250
http://poj.org/problem?id=1094原来拓扑序可以这样做,原来一直sb的用白书上说的dfs。。。。。。。。。。。。拓扑序只要每次将入度为0的点加入栈,然后每次拓展维护入度即可。。我是个大sb,这种水题调了一早上。。#include #include #include #inc...
分类:
其他好文 时间:
2014-10-01 12:16:31
阅读次数:
172
本文由哈利_蜘蛛侠原创,转载请注明出处!有问题请联系2024958085@qq.com
这一次我们继续来讲述Jim Adams 老哥的RPG编程书籍第二版第二章的第10节:Particles (粒子),第11节:Depth Sorting and Z-Buffering (深度排序和Z-缓存),以及第12节:Working with Viewports (使用视口)。这两节...
1, Sort
Needless to say, mongodb also support to sort data. THe positive one means sorting by asc order and negetive means by desc.
2. Group
The grammar of group:
Description Of Argument:...
分类:
数据库 时间:
2014-09-23 02:47:33
阅读次数:
267
一、排序的两种方式(1)原地排序(In-place sorting):按指定的顺序排列数据,然后用排序后的数据替换原来的数据,原来的数据丢失。sort(),列表的标准方法,e.g. mylist.sort()(2)复制排序(Copied sorting):按指定的顺序排列数据,然后返回原数据一个有序...
分类:
编程语言 时间:
2014-09-23 00:04:13
阅读次数:
310
Collection of algorithm for sorting
heap sort 堆排序
The heapsort algorithm can be divided into two parts.
In the first step, a heap is built out
of the data. The h...
分类:
其他好文 时间:
2014-09-19 19:24:45
阅读次数:
220
题目:n个叠放在一起的卡片,求使得他们同向的最小翻转次数,每次只能翻转最上面的k个。
分析:数学,贪心。每次翻转必然是不同情况(正,反)交接的地方(否则只会变得更糟);
记交接的地方的个数为m,那么翻转后交接的地方变为m-1或m;
(上面部分两端相同则为m-1,不同则为m)
因此一次翻转最多使得交接点减少1;所以每次翻...
分类:
其他好文 时间:
2014-09-16 12:44:30
阅读次数:
158
Collection of algorithm for sorting...
分类:
其他好文 时间:
2014-09-14 16:43:27
阅读次数:
210