上一页 1 2 3 4 5 6 7 ··· 11 下一页

2013年9月12日

zoj 1119 / poj 1523 SPF (典型例题 求割点 Tarjan 算法)

摘要: poj :http://poj.org/problem?id=1523如果无向图中一个点 u 为割点 则u 或者是具有两个及以上子女的深度优先生成树的根,或者虽然不是一个根,但是它有一个子女 w, 使得low[w] >= dfn[u];其中low[u] 是指点 u 通过回边所能达到的 最小深度优先数,dfn[u]是指 点u 当前所处的 深度优先数;low[u] 是在递归回退时计算出来的,dfn[u] 是在递归时直接计算的。low[u] = min{ dfn[u]; min{ low[w] } // w是u的一个子女 min{ dfn[v] } // v与u邻接, 且(u,v)是一条回边. 阅读全文

posted @ 2013-09-12 19:16 圣手摘星 阅读(399) 评论(0) 推荐(0) 编辑

2013年8月16日

刘汝佳 算法竞赛-入门经典 第二部分 算法篇 第六章 2(Binary Trees)

摘要: 112 - Tree Summing 题目大意:给出一个数,再给一颗树,每个头节点的子树被包含在头节点之后的括号里,寻找是否有从头节点到叶子的和与给出的数相等,如果有则输出yes,没有输出no! 解题思路:按照括号匹配的原则,调用栈,求从头节点到叶子节点的和! 解题代码: 1 //Author :Freetion 2 //file :112 - Tree Summing 3 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 10 #define Local11 int ... 阅读全文

posted @ 2013-08-16 15:59 圣手摘星 阅读(297) 评论(0) 推荐(0) 编辑

2013年8月6日

刘汝佳 算法竞赛-入门经典 第二部分 算法篇 第六章 1(Lists)

摘要: 127-"Accordian" Patience题目大意:一个人一张张发牌,如果这张牌与这张牌前面的一张或者前面的第三张(后面称之为一位置和三位置)的点数或花式相同,则将这张牌移动到与之对应的位置(优先三位置,也就是说如果一位置与三位置都有以上的性质则移动到三位置之上),移动之后若仍以上的性质,则继续操作,直到已发的所有牌都无法移动之后再继续发牌,(如果一个位置被移空,则删除此位置!)解题思路:用数组模拟链表,每发一张牌就匹配三位置,如果匹配就移动,否则再看一位置是否满足,如果满足就移动,移动之后,再继续之前的操作,直到所有的都不能移动!如果都不满足,则继续发牌!如此反复直 阅读全文

posted @ 2013-08-06 21:21 圣手摘星 阅读(440) 评论(0) 推荐(0) 编辑

2013年7月28日

刘汝佳 算法竞赛-入门经典 第二部分 算法篇 第五章 3(Sorting/Searching)

摘要: 第一题:340 - Master-Mind HintsUVA:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=98&page=show_problem&problem=276题目大意:给定密码长度,然后是密码占一行,然后每一行是一个猜测,需要找出这行猜测有几个位置相同且密码相同的个数,几个位置不同但密码匹配的个数;前者个数为A,后者个数为B,匹配优先前者比如说密码为 1 2 3 4,猜测为 2 2 1 3,则A = 1, B = 2。读入直到猜测都为0。解 阅读全文

posted @ 2013-07-28 21:55 圣手摘星 阅读(382) 评论(0) 推荐(0) 编辑

2013年7月26日

刘汝佳 算法竞赛-入门经典 第二部分 算法篇 第五章 2(Big Number)

摘要: 这里的高精度都是要去掉前导0的,第一题:424 - Integer InquiryUVA:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=97&page=show_problem&problem=365解题思路:模拟手动加法的运算过程,写一个高精度整数加法就可以了;减法,乘法,除法同样也是模拟手动过程。解题代码: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #inc 阅读全文

posted @ 2013-07-26 11:36 圣手摘星 阅读(408) 评论(0) 推荐(0) 编辑

2013年7月21日

刘汝佳 算法竞赛-入门经典 第二部分 算法篇 第五章 1(String)

摘要: 第一题:401 - PalindromesUVA :http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=342解题思路:此题很水,只要把mirrored string 类的对应关系搞对,基本就可以了!但是细节要注意,首先只有一个元素的时候需要单独判断,一个字符是回文串,是不是mirrored string 则需要判断,另外最后输出中间隔了一行!解题代码: 1 // File Name: 刘汝佳-基础/p 阅读全文

posted @ 2013-07-21 01:46 圣手摘星 阅读(275) 评论(0) 推荐(0) 编辑

2013年7月20日

POJ 1002 487-3279

摘要: 题目链接:http://poj.org/problem?id=1002&lang=zh-CN接替思路;先把字符串转换成数字或数字串,第一次写的代码是数字串,调用了stirng,和map 所以花时较长 1500ms,第二次用数字800ms!第一次代码: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 const int max_n = 1e5+3; 9 10 string str[max_n], str2, str3[max_n];11 map p_... 阅读全文

posted @ 2013-07-20 19:29 圣手摘星 阅读(148) 评论(0) 推荐(0) 编辑

2013年7月19日

HDU 1548 A strange lift (Dijkstra)

摘要: A strange lifthttp://acm.hdu.edu.cn/showproblem.php?pid=1548Problem DescriptionThere is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 6 #include 7 #include 8 using namespace std; 9 10 const int INF = 0x3fffffff;11 const int max_n = 202;12 int k[max_n]... 阅读全文

posted @ 2013-07-19 19:22 圣手摘星 阅读(206) 评论(0) 推荐(0) 编辑

HDU 1217 Arbitrage (Floyd)

摘要: Arbitragehttp://acm.hdu.edu.cn/showproblem.php?pid=1217Problem DescriptionArbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For example, suppose that 1 US Dollar buys 0.5 British pound, 1 British pound b 阅读全文

posted @ 2013-07-19 17:02 圣手摘星 阅读(174) 评论(0) 推荐(0) 编辑

HDU 1385 Minimum Transport Cost (Dijstra 最短路)

摘要: Minimum Transport Costhttp://acm.hdu.edu.cn/showproblem.php?pid=1385Problem DescriptionThese are N cities in Spring country. Between each pair of cities there may be one transportation track or none. Now there is some cargo that should be delivered from one city to another. The transportation fee co 阅读全文

posted @ 2013-07-19 15:36 圣手摘星 阅读(239) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 ··· 11 下一页

导航