摘要: Cow ContestDescriptionN (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all know, some cows code bet... 阅读全文
posted @ 2014-07-24 15:42 Enumz 阅读(294) 评论(0) 推荐(0) 编辑
摘要: WormholesDescriptionWhile exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it i... 阅读全文
posted @ 2014-07-24 15:15 Enumz 阅读(213) 评论(-1) 推荐(0) 编辑
摘要: ArbitrageDescriptionArbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of th... 阅读全文
posted @ 2014-07-24 15:02 Enumz 阅读(261) 评论(0) 推荐(0) 编辑
摘要: The Fewest CoinsDescriptionFarmer John has gone to town to buy some farm supplies. Being a very efficient man, he always pays for his goods in such a ... 阅读全文
posted @ 2014-07-24 14:52 Enumz 阅读(245) 评论(0) 推荐(0) 编辑
摘要: 邻接表 邻接矩阵来存储图的信息相对于非完全图,会浪费大量的空间,同时在求最短路径的时候也会有多余的计算浪费时间。 使用邻接表可以节约这些浪费的时间。 这里介绍的是用数组模拟的邻接表: 定义begin[MAXN],end[MAXN],dis[MAXN],first[MAXN],next[MAX... 阅读全文
posted @ 2014-07-23 14:35 Enumz 阅读(929) 评论(0) 推荐(0) 编辑
摘要: SPAF算法求单源最短路的SPFA算法的全称是:Shortest Path Faster Algorithm,该算法是西南交通大学段凡丁于1994年发表的。它可以在O(kE)的时间复杂度内求出源点到其他所有点的最短路径。其中k为所有顶点进队的平均次数,可以证明k一般小于等于2,可以处理负边,但无法处... 阅读全文
posted @ 2014-07-23 11:55 Enumz 阅读(296) 评论(0) 推荐(0) 编辑
摘要: Bellman-Ford算法Dijkstra算法无法判断含负权边的图的最短路。如果遇到负权,在没有负权回路存在时,即便有负权的边,也可以采用Bellman-Ford算法正确求出最短路径。PS:负权回路的含义是,回路的权值和为负。算法描述1.初始化:将除源点外的所有顶点的最短距离估计值d[v]←+∞,... 阅读全文
posted @ 2014-07-23 11:51 Enumz 阅读(256) 评论(0) 推荐(0) 编辑
摘要: Dijkstra算法 Dijkstra算法主要特点是以起始点为中心向外层层扩展,直到扩展到终点为止。 注意该算法要求图中不存在负权边。 首先我们来定义一个二维数组Edge[MAXN][MAXN]来存储图的信息。 这个图的Edge数组初始化以后为 我们还需要用一个一维数组dis来存储... 阅读全文
posted @ 2014-07-23 11:45 Enumz 阅读(237) 评论(0) 推荐(0) 编辑
摘要: Invitation CardsDescriptionIn the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this f... 阅读全文
posted @ 2014-07-22 16:48 Enumz 阅读(706) 评论(1) 推荐(0) 编辑
摘要: A strange liftDescriptionThere is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 2 #include 3 #include 4... 阅读全文
posted @ 2014-07-22 15:51 Enumz 阅读(322) 评论(0) 推荐(0) 编辑