03 2015 档案

摘要:poj——2031 最小生成树(MST) Kruskal算法Building a Space StationTime Limit:1000MSMemory Limit:30000KTotal Submissions:4985Accepted:2503DescriptionYou are a memb... 阅读全文
posted @ 2015-03-31 21:01 __560 阅读(373) 评论(0) 推荐(0) 编辑
摘要:poj3122——二分查找PieTime Limit:1000MSMemory Limit:65536KTotal Submissions:11698Accepted:4050Special JudgeDescriptionMy birthday is coming up and tradition... 阅读全文
posted @ 2015-03-31 14:42 __560 阅读(256) 评论(0) 推荐(0) 编辑
摘要:poj1905——二分法求单调函数零点解方程Expanding RodsTime Limit:1000MSMemory Limit:30000KTotal Submissions:12773Accepted:3291DescriptionWhen a thin rod of length L is ... 阅读全文
posted @ 2015-03-31 13:17 __560 阅读(612) 评论(0) 推荐(0) 编辑
摘要:poj3258——二分优化River HopscotchTime Limit:2000MSMemory Limit:65536KTotal Submissions:8201Accepted:3531DescriptionEvery year the cows hold an event featur... 阅读全文
posted @ 2015-03-30 17:27 __560 阅读(240) 评论(0) 推荐(0) 编辑
摘要:poj3273——经典的二分优化Monthly ExpenseTime Limit:2000MSMemory Limit:65536KTotal Submissions:16522Accepted:6570DescriptionFarmer John is an astounding account... 阅读全文
posted @ 2015-03-30 10:55 __560 阅读(297) 评论(0) 推荐(0) 编辑
摘要:poj1061——扩展gcd水题青蛙的约会Time Limit:1000MSMemory Limit:10000KTotal Submissions:94176Accepted:17413Description两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一... 阅读全文
posted @ 2015-03-27 23:00 __560 阅读(331) 评论(0) 推荐(0) 编辑
摘要:poj2115——拓展欧几里德求模线性同余方程的最小正整数解C LooooopsTime Limit:1000MSMemory Limit:65536KTotal Submissions:18926Accepted:4973DescriptionA Compiler Mystery: We are ... 阅读全文
posted @ 2015-03-27 20:38 __560 阅读(321) 评论(0) 推荐(0) 编辑
摘要:拓展欧几里德算法对贝祖等式:ax+by=gcd(a,b); 一定存在整数解,求x最小的整数解x,y (x,y可以是负数)#include#include#include#include#includeusing namespace std;const int maxn=1000100;const i... 阅读全文
posted @ 2015-03-27 19:21 __560 阅读(248) 评论(0) 推荐(0) 编辑
摘要:poj1845——二分递归求等比数列前n项和,根号剪枝SumdivTime Limit:1000MSMemory Limit:30000KTotal Submissions:15268Accepted:3764DescriptionConsider two natural numbers A and... 阅读全文
posted @ 2015-03-26 23:34 __560 阅读(442) 评论(0) 推荐(0) 编辑
摘要:打印素数表筛选法void play_prime(){ //打印isprime(bool)表 memset(isprime,1,sizeof(isprime)); isprime[1]=0; for(int i=2;i<maxn;i++){ if(!isprime... 阅读全文
posted @ 2015-03-26 00:29 __560 阅读(225) 评论(0) 推荐(0) 编辑
摘要:poj3292——筛选法Semi-prime H-numbersTime Limit:1000MSMemory Limit:65536KTotal Submissions:7772Accepted:3360DescriptionThis problem is based on an exercise... 阅读全文
posted @ 2015-03-26 00:13 __560 阅读(209) 评论(0) 推荐(0) 编辑
摘要:poj2635——同余模定理,打印素数表The Embarrassed CryptographerTime Limit:2000MSMemory Limit:65536KTotal Submissions:12603Accepted:3367DescriptionThe young and very... 阅读全文
posted @ 2015-03-25 21:03 __560 阅读(270) 评论(0) 推荐(0) 编辑
摘要:poj1942——组合数学Paths on a GridTime Limit:1000MSMemory Limit:30000KTotal Submissions:22473Accepted:5522DescriptionImagine you are attending your math les... 阅读全文
posted @ 2015-03-25 17:46 __560 阅读(246) 评论(0) 推荐(0) 编辑
摘要:poj3252——组合数学Round NumbersTime Limit:2000MSMemory Limit:65536KTotal Submissions:9790Accepted:3517DescriptionThe cows, as you know, have no fingers or ... 阅读全文
posted @ 2015-03-25 11:32 __560 阅读(242) 评论(0) 推荐(0) 编辑
摘要:hduoj1753——java大明A+BTime Limit: 3000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9321Accepted Submission(s): 33... 阅读全文
posted @ 2015-03-25 02:04 __560 阅读(247) 评论(0) 推荐(0) 编辑
摘要:poj1019——log10求位数Number SequenceTime Limit:1000MSMemory Limit:10000KTotal Submissions:35084Accepted:10099DescriptionA single positive integer i is giv... 阅读全文
posted @ 2015-03-24 21:36 __560 阅读(291) 评论(0) 推荐(0) 编辑
摘要:poj2084——卡特兰数Game of ConnectionsTime Limit:1000MSMemory Limit:30000KTotal Submissions:7647Accepted:3865DescriptionThis is a small but ancient game. Yo... 阅读全文
posted @ 2015-03-24 13:56 __560 阅读(254) 评论(0) 推荐(0) 编辑
摘要:hdoj1023——卡特兰数Train Problem IITime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6418Accepted Submiss... 阅读全文
posted @ 2015-03-24 13:33 __560 阅读(207) 评论(0) 推荐(0) 编辑
摘要:poj1496——组合数学Word IndexTime Limit:1000MSMemory Limit:10000KTotal Submissions:4740Accepted:2692DescriptionEncoding schemes are often used in situations... 阅读全文
posted @ 2015-03-23 23:13 __560 阅读(234) 评论(0) 推荐(0) 编辑
摘要:poj1850——组合数学CodeTime Limit:1000MSMemory Limit:30000KTotal Submissions:8492Accepted:4020DescriptionTransmitting and memorizing information is a task t... 阅读全文
posted @ 2015-03-23 23:08 __560 阅读(225) 评论(0) 推荐(0) 编辑
摘要:bestcoder#29 1002 矩阵连乘快速幂解fib数列GTY's birthday gift Accepts: 103 Submissions: 585 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K... 阅读全文
posted @ 2015-03-23 13:28 __560 阅读(290) 评论(0) 推荐(0) 编辑
摘要:bestcoder#28 1002 dfsFibonacci Accepts: 40 Submissions: 996 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Proble... 阅读全文
posted @ 2015-03-23 00:52 __560 阅读(230) 评论(0) 推荐(0) 编辑
摘要:poj1458——dp,lcsCommon SubsequenceTime Limit:1000MSMemory Limit:10000KTotal Submissions:40529Accepted:16351DescriptionA subsequence of a given sequence... 阅读全文
posted @ 2015-03-22 00:53 __560 阅读(212) 评论(0) 推荐(0) 编辑
摘要:排序Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 38410Accepted Submission(s): 10894Problem Descri... 阅读全文
posted @ 2015-03-21 17:35 __560 阅读(293) 评论(0) 推荐(0) 编辑
摘要:codeforces#296div2_b 字符串,图B. Error Correct Systemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outpu... 阅读全文
posted @ 2015-03-21 16:04 __560 阅读(289) 评论(0) 推荐(0) 编辑
摘要:codeforces#296div2_a 模拟A. Playing with Papertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne... 阅读全文
posted @ 2015-03-21 15:56 __560 阅读(273) 评论(0) 推荐(0) 编辑
摘要:hduoj1159 dp,lcsCommon SubsequenceTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 25570Accepted Su... 阅读全文
posted @ 2015-03-21 01:35 __560 阅读(197) 评论(0) 推荐(0) 编辑
摘要:poj1159——回文,lcsPalindromeTime Limit:3000MSMemory Limit:65536KTotal Submissions:54621Accepted:18892DescriptionA palindrome is a symmetrical string, tha... 阅读全文
posted @ 2015-03-21 01:00 __560 阅读(216) 评论(0) 推荐(0) 编辑
摘要:hduoj1025——dp, lisConstructing Roads In JGShining's KingdomTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submis... 阅读全文
posted @ 2015-03-20 23:27 __560 阅读(261) 评论(0) 推荐(0) 编辑
摘要:poj1080——lcs变形,dpHuman Gene FunctionsTime Limit:1000MSMemory Limit:10000KTotal Submissions:17610Accepted:9821DescriptionIt is well known that a human ... 阅读全文
posted @ 2015-03-20 21:11 __560 阅读(229) 评论(0) 推荐(0) 编辑
摘要:lis(最长上升子序列) dp求序列的lis,子序列可不连续 for(int i=1;ians) ans=dp[i]; } printf("%d\n",ans);View Code上面的算法是n^2的,现在补充nlogn的算法,下面算法手动模拟一下不难理解#include#incl... 阅读全文
posted @ 2015-03-20 19:59 __560 阅读(324) 评论(0) 推荐(0) 编辑
摘要:lcs(最长公共子序列)求两个序列的lcs的长度,子序列可不连续dp[i][j]=dp[i-1][j-1]+1(a[i]==b[i])dp[i][j]=max(dp[i-1][j],dp[i][j-1])(a[i]!=b[i]) memset(dp,0,sizeof(dp)); for(... 阅读全文
posted @ 2015-03-20 19:56 __560 阅读(274) 评论(0) 推荐(0) 编辑
摘要:poj3176——dpCow BowlingTime Limit:1000MSMemory Limit:65536KTotal Submissions:14683Accepted:9764DescriptionThe cows don't use actual bowling balls when ... 阅读全文
posted @ 2015-03-20 18:32 __560 阅读(200) 评论(0) 推荐(0) 编辑
摘要:poj2533——lis(最长上升子序列), 线性dpLongest Ordered SubsequenceTime Limit:2000MSMemory Limit:65536KTotal Submissions:36143Accepted:15876DescriptionA numeric se... 阅读全文
posted @ 2015-03-20 18:17 __560 阅读(211) 评论(0) 推荐(0) 编辑
摘要:poj1260——线性dpPearlsTime Limit:1000MSMemory Limit:10000KTotal Submissions:7705Accepted:3811DescriptionIn Pearlania everybody is fond of pearls. One com... 阅读全文
posted @ 2015-03-20 12:35 __560 阅读(215) 评论(0) 推荐(0) 编辑
摘要:poj1836——dp,最长上升子序列(lis)AlignmentTime Limit:1000MSMemory Limit:30000KTotal Submissions:13767Accepted:4450DescriptionIn the army, a platoon is composed... 阅读全文
posted @ 2015-03-20 00:12 __560 阅读(267) 评论(0) 推荐(0) 编辑
摘要:poj3267——线性dpThe Cow LexiconTime Limit:2000MSMemory Limit:65536KTotal Submissions:8458Accepted:3993DescriptionFew know that the cows have their own di... 阅读全文
posted @ 2015-03-19 22:20 __560 阅读(207) 评论(0) 推荐(0) 编辑
摘要:背包问题目前已经学了三种背包问题,是时候整理一下模版了01背包这是最基础的背包问题,即每件物品只能取一次,问背包能装的不超过容量的最大价值方程:dp[i][j]=max{dp[i-1][j],dp[i-1][j-w[i]]+val[i]}(j>=w[i]) 边界:dp[i][j]=dp[i-1... 阅读全文
posted @ 2015-03-18 22:14 __560 阅读(276) 评论(0) 推荐(0) 编辑
摘要:poj1276——dp,多重背包Cash MachineTime Limit:1000MSMemory Limit:10000KTotal Submissions:28826Accepted:10310DescriptionA Bank plans to install a machine for ... 阅读全文
posted @ 2015-03-18 21:39 __560 阅读(241) 评论(0) 推荐(0) 编辑
摘要:hihocoder1038 01背包时间限制:20000ms单点时限:1000ms内存限制:256MB描述且说上一周的故事里,小Hi和小Ho费劲心思终于拿到了茫茫多的奖券!而现在,终于到了小Ho领取奖励的时刻了!小Ho现在手上有M张奖券,而奖品区有N件奖品,分别标号为1到N,其中第i件奖品需要nee... 阅读全文
posted @ 2015-03-18 17:44 __560 阅读(272) 评论(0) 推荐(0) 编辑
摘要:POJ 1384 dp,完全背包Piggy-BankTime Limit:1000MSMemory Limit:10000KTotal Submissions:8404Accepted:4082DescriptionBefore ACM can do anything, a budget must ... 阅读全文
posted @ 2015-03-17 23:19 __560 阅读(370) 评论(0) 推荐(0) 编辑
摘要:POJ 1837 dpBalanceTime Limit:1000MSMemory Limit:30000KTotal Submissions:11278Accepted:7017DescriptionGigel has a strange "balance" and he wants to poi... 阅读全文
posted @ 2015-03-16 11:30 __560 阅读(242) 评论(0) 推荐(0) 编辑
摘要:POJ 3982 大数序列Time Limit:1000MSMemory Limit:65536KTotal Submissions:7191Accepted:3243Description数列A满足An = An-1 + An-2 + An-3, n >= 3编写程序,给定A0, A1 和 A2,... 阅读全文
posted @ 2015-03-16 00:03 __560 阅读(187) 评论(0) 推荐(0) 编辑
摘要:poj3624 01背包 dp+滚动数组Charm BraceletTime Limit:1000MSMemory Limit:65536KTotal Submissions:25458Accepted:11455DescriptionBessie has gone to the mall's je... 阅读全文
posted @ 2015-03-15 23:11 __560 阅读(322) 评论(0) 推荐(0) 编辑
摘要:JAVA——A+B——————我的第一道JAVATime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 241566Accepted Submission(... 阅读全文
posted @ 2015-03-15 15:37 __560 阅读(495) 评论(0) 推荐(0) 编辑
摘要:bestcoder#33 1002 快速幂取余+模拟乘,组合数学zhx's contestTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 831Ac... 阅读全文
posted @ 2015-03-15 10:31 __560 阅读(230) 评论(0) 推荐(0) 编辑
摘要:快速幂模版快速幂的思想是分治,根据题目的数据要注意long long快速幂普通版,比取余版快,但容易超范围,慎用,一般可用取余版MOD设为INF://快速幂普通版(未取余)long long quickpow(long long n,long long k){ long long res=1;... 阅读全文
posted @ 2015-03-15 01:27 __560 阅读(325) 评论(0) 推荐(0) 编辑
摘要:bestcoder#33 1001 高精度模拟zhx's submissionsTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 0Accepted ... 阅读全文
posted @ 2015-03-14 23:54 __560 阅读(291) 评论(0) 推荐(0) 编辑
摘要:POJ 2446 二分图的最大匹配匈牙利算法ChessboardTime Limit:2000MSMemory Limit:65536KTotal Submissions:14350Accepted:4471DescriptionAlice and Bob often play games on c... 阅读全文
posted @ 2015-03-14 15:19 __560 阅读(213) 评论(0) 推荐(0) 编辑
摘要:POJ 3984 bfs+回溯路径迷宫问题Time Limit:1000MSMemory Limit:65536KTotal Submissions:9218Accepted:5459Description定义一个二维数组:int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1... 阅读全文
posted @ 2015-03-14 14:56 __560 阅读(499) 评论(0) 推荐(0) 编辑
摘要:POJ 1129 dfs 四色问题Channel AllocationTime Limit:1000MSMemory Limit:10000KTotal Submissions:12799Accepted:6558DescriptionWhen a radio station is broadcas... 阅读全文
posted @ 2015-03-14 13:22 __560 阅读(358) 评论(0) 推荐(0) 编辑
摘要:POJ 2676 dfsSudokuTime Limit:2000MSMemory Limit:65536KTotal Submissions:14640Accepted:7217Special JudgeDescriptionSudoku is a very simple task. A squa... 阅读全文
posted @ 2015-03-14 00:29 __560 阅读(252) 评论(0) 推荐(0) 编辑
摘要:POJ 1416 dfs递归枚举+记录路径Shredding CompanyTime Limit:1000MSMemory Limit:10000KTotal Submissions:4456Accepted:2555DescriptionYou have just been put in char... 阅读全文
posted @ 2015-03-13 19:24 __560 阅读(307) 评论(0) 推荐(0) 编辑
摘要:bfs算法模版写过很多bfs题,每次写bfs代码习惯都略有不同,有些糟糕的代码习惯影响了解题速度下面这份简单的三维bfs可以算是写得比较不错的一份了,以后按这种习惯写,虽然没有写回溯路径,但回溯路径很简单,只要加个fa数组就行了,所以就不加在模版上了//bfs模版int X,Y,Z;char ch[... 阅读全文
posted @ 2015-03-13 14:43 __560 阅读(420) 评论(0) 推荐(0) 编辑
摘要:POJ 2531 dfs递归枚举Network SaboteurTime Limit:2000MSMemory Limit:65536KTotal Submissions:9580Accepted:4560DescriptionA university network is composed of ... 阅读全文
posted @ 2015-03-13 14:33 __560 阅读(353) 评论(0) 推荐(0) 编辑
摘要:POJ 1326 对数位的bfsPrime PathTime Limit:1000MSMemory Limit:65536KTotal Submissions:12480Accepted:7069DescriptionThe ministers of the cabinet were quite u... 阅读全文
posted @ 2015-03-13 12:01 __560 阅读(224) 评论(0) 推荐(0) 编辑
摘要:POJ 1426 数的bfs,打表Find The MultipleTime Limit:1000MSMemory Limit:10000KTotal Submissions:19409Accepted:7868Special JudgeDescriptionGiven a positive int... 阅读全文
posted @ 2015-03-13 10:53 __560 阅读(399) 评论(0) 推荐(0) 编辑
摘要:POJ 3278 对数轴进行一维bfsCatch That CowTime Limit:2000MSMemory Limit:65536KTotal Submissions:52161Accepted:16355DescriptionFarmer John has been informed of... 阅读全文
posted @ 2015-03-13 10:03 __560 阅读(329) 评论(0) 推荐(0) 编辑
摘要:POJ 2251 bfsDungeon MasterTime Limit:1000MSMemory Limit:65536KTotal Submissions:18245Accepted:7075DescriptionYou are trapped in a 3D dungeon and need ... 阅读全文
posted @ 2015-03-13 00:18 __560 阅读(279) 评论(0) 推荐(0) 编辑
摘要:POJ 1321 DFS回溯+递归枚举棋盘问题Time Limit:1000MSMemory Limit:10000KTotal Submissions:24813Accepted:12261Description在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的... 阅读全文
posted @ 2015-03-12 23:44 __560 阅读(271) 评论(0) 推荐(0) 编辑
摘要:hduoj 2553 dfs,回溯N皇后问题Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10297Accepted Submission(s):... 阅读全文
posted @ 2015-03-12 23:25 __560 阅读(333) 评论(0) 推荐(0) 编辑
摘要:POJ 3009 迭代加深搜索Curling 2.0Time Limit:1000MSMemory Limit:65536KTotal Submissions:12986Accepted:5460DescriptionOn Planet MM-21, after their Olympic game... 阅读全文
posted @ 2015-03-12 20:25 __560 阅读(336) 评论(0) 推荐(0) 编辑
摘要:bestcoder#32 1002 哈希+后缀数组 Negative and Positive (NP) Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission( 阅读全文
posted @ 2015-03-12 15:29 __560 阅读(233) 评论(0) 推荐(0) 编辑
摘要:POJ 3083 dfs+bfs+模拟Children of the Candy CornTime Limit:1000MSMemory Limit:65536KTotal Submissions:10564Accepted:4539DescriptionThe cornfield maze is... 阅读全文
posted @ 2015-03-11 23:18 __560 阅读(318) 评论(0) 推荐(0) 编辑
摘要:POJ 2513 Colored Sticks欧拉回路判定,并查集,trie树Time Limit:5000MSMemory Limit:128000KTotal Submissions:31621Accepted:8370DescriptionYou are given a bunch of w... 阅读全文
posted @ 2015-03-11 20:21 __560 阅读(361) 评论(0) 推荐(0) 编辑
摘要:= = 阅读全文
posted @ 2015-03-11 17:59 __560 阅读(180) 评论(1) 推荐(0) 编辑
摘要:最大流增广路算法Edmonds_Karp算法:通过bfs从零流开始不断寻找增广路,当无法在增广时,此时流为最大流/* Edmonds_Karp算法 */int cap[maxn][maxn],flow[maxn][maxn]; //cap容量,flow流量,相减得残量int Edmonds_Kar... 阅读全文
posted @ 2015-03-11 16:28 __560 阅读(231) 评论(0) 推荐(0) 编辑
摘要:字典树trie又称单词查找树,trie树,是一种树形结构,是一种哈希树的变种。典型应用是用于统计,排序和保存大量的字符串(但不仅限于字符串),所以经常被搜索引擎系统用于文本词频统计。它的优点是:利用字符串的公共前缀来减少查询时间,最大限度地减少无谓的字符串比较,查询效率比哈希表高。(这段来自百度百科... 阅读全文
posted @ 2015-03-11 16:20 __560 阅读(254) 评论(0) 推荐(0) 编辑
摘要:哈希技术哈希技术应用广泛,可用于判重,存取,查询,降低时间复杂度;哈希可用STL中的set代替哈希可用STL中的setset ss;ss.insert(t); //插入if(ss.find(a)!=ss.end())... //找到ss.clear(); //清空STL_set哈希模版const i... 阅读全文
posted @ 2015-03-11 16:13 __560 阅读(325) 评论(0) 推荐(0) 编辑
摘要:哈夫曼树——贪心哈夫曼树:给定n个权值作为n的叶子结点,构造一棵二叉树,若带权路径长度达到最小,称这样的二叉树为最优二叉树,也称为哈夫曼树(Huffman tree)。哈夫曼树是带权路径长度 最短的树,权值较大的结点离根较近。此类题目一般求算哈夫曼树路径总值,利用贪心选择性质每次从队... 阅读全文
posted @ 2015-03-11 16:06 __560 阅读(1078) 评论(0) 推荐(0) 编辑
摘要:归并排序——计算逆序数归并排序用了分治的思想,时间复杂度o(N*logN)动态内存的运用可减小空间开销; 归并排序还可用于计算逆序数; 逆序数:序列中位置和大小相反的一对数字; 逆序数=冒泡排序中相邻两个数字交换的次数;int a[maxn],n;long long ans; //... 阅读全文
posted @ 2015-03-11 15:58 __560 阅读(539) 评论(0) 推荐(0) 编辑
摘要:二分图的匈牙利算法 二分图的难点主要在建图; 关于二分图的几个重要公式: 最大匹配数=最小点覆盖 最小边覆盖=顶点总数-最大匹配数/2 (这个要拆点:uN=vN=cnt,ans=cnt-hungary/2) 最大团=补图最大独立集 最大独立集=顶点数-最大匹配 匈牙利算法: 顶点编号 u= 1~uN 阅读全文
posted @ 2015-03-11 15:49 __560 阅读(249) 评论(0) 推荐(0) 编辑
摘要:拓扑排序拓扑排序主要有无前驱,无后继和dfs三种方法; 若只需判断是否为拓扑序列(DAG),可用上述拓扑排序看是否排序成功,也可用floyd传递闭包;无前驱的拓扑排序法:/* 无前驱的拓扑排序法 */bool toposort(){ queue q; while(!ans.empty()... 阅读全文
posted @ 2015-03-11 15:39 __560 阅读(261) 评论(0) 推荐(0) 编辑
摘要:读入外挂当题目坑到连scanf都TLE的时候可试试读入外挂---inline int getint() //inline为内联函数,目的是预处理,可减少时间{ char c=getchar(); while(c!='-'&&!isdigit(c)) c=getchar(); int... 阅读全文
posted @ 2015-03-11 15:25 __560 阅读(330) 评论(0) 推荐(0) 编辑
摘要:最小生成树最小生成树即用最少的边权将所有给定的点连在同一联通分量中,常用kruskal和prim算法kruskal算法(适合稀疏图)最小生成树的kruskal算法,稍带并查集的应用int find(int x){ return fa[x]==x?x:fa[x]=find(fa[x]); //不... 阅读全文
posted @ 2015-03-11 15:18 __560 阅读(485) 评论(0) 推荐(0) 编辑
摘要:最短路算法dijkstra(初级的最短路算法,适合稠密图,可用邻接表优化)bool relax(int u,int v){ double tmp=max(dist[u],edge[u][v]); if(tmpv=v;p->w=w; p->next=pre->next; pre... 阅读全文
posted @ 2015-03-11 15:11 __560 阅读(413) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示