![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
POJ-北大
Paul-Yang
天道酬勤
展开
-
POJ 1789 Truck History 最小生成树 kruskal && Prim
Truck History 克鲁斯卡尔 最小生成树,两两不同个数为权值, Description Advanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture, or for bricks. The company has its own code describing each type of a原创 2015-08-11 19:52:10 · 392 阅读 · 0 评论 -
POJ 2075 Tangled in Cables 最小生成树 Kruskal && Prim
最小生成树 , Kruscal && Prim ,将房屋转变为编号,就是一 模板题 You are the owner of SmallCableCo and have purchased the franchise rights for a small town. Unfortunately, you lack enough funds to start your business properly and are relying on parts you have found in an o原创 2015-08-13 18:57:55 · 469 阅读 · 0 评论 -
POJ 1751 Highways 最小生成树 Kruskal && Prim
最小生成树 Kruscal && Prim 给定n个城市,给定了已经连接起来的道路,输出的是城镇的编号, The island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has a very poor system of public highways. The Flatopian government is aware of this problem and has already constructed a num原创 2015-08-13 18:44:15 · 511 阅读 · 0 评论 -
POJ 2235 Frogger 最小生成树 Kruskal && Prim
Frogger 最小生成树 Kruscal && Prim 给出两只青蛙的坐标A、B,和其他的n-2个坐标,任一两个坐标点间都是双向连通的。 显然从A到B存在至少一条的通路,每一条通路的元素都是这条通路中前后两个点的距离, 这些距离中又有一个最大距离。 要求: 他最小的弹跳距离是多少(即最短路径中的最长边)。 在生成最小生成树时,只要 A,B 连一起后,其余的点就不用再连 (不需要把所有的点都连起来) 最小生成树 Kruscal rim 模原创 2015-08-13 19:05:53 · 885 阅读 · 0 评论 -
POJ 3984 迷宫问题 (BFS)
POJ 3984 迷宫问题 (BFS) 思路: 迷宫是一个5 × 5的二维数组,从左上角(0, 0)位置开始,上下左右进行搜索,可以定义两个数组,即 dx[4]={1,-1,0,0};:表示x方向的变化;dy[4]={0,0,-1,1};:表示y方向的变化。 二者结合就是一个点可以上下左右移动。对于数组中的每个元素用结构体来存储,除了有x,y成员外,还要定义head,(如同邻接表)用来表示从左上角到右下角的最短路径中每个元素的前一个元素的下标,即保存路径。 注意:搜索的元素是否在迷宫内,是否原创 2015-08-20 16:49:51 · 1485 阅读 · 0 评论 -
POJ 3259 Wormholes (最短路 SPFA 判断负环)
POJ 3259 Wormholes (最短路 SPFA 判断负环) 题意: N个农场旅行 有M个路径 和 W个虫洞。 有M行 普通路径 S ,E, T。表示从地点S(E)到地点E(S)的时间为T。接着有W行为虫洞。普通路径是双向的, 虫洞是单向,且为负值 思路:既有虫洞又有普通道路,把虫洞看成是一条负权路,问题就转化成 求一个图中是否存在负权回路 。 定义一个数组记录入队次数,每个元素 入队次数是否小于 N 。原创 2015-08-20 10:34:17 · 435 阅读 · 0 评论 -
POJ 3687 Labeling Balls (反向拓扑排序)
POJ 3687 Labeling Balls (反向拓扑排序) 使得小的结点尽可能的排在前面:需要 反向 拓扑排序 如:5->6->1; 4->3->2 应让结点1尽量排在前面,再使2尽量排在前面... ...:5 6 1 4 3 2 若直接按结点从小到大拓扑排序,无法得到正解: 4 3 2 5 6 1 反向拓扑排序,按结点从大到小的顺序这样能使结点小的尽可能的排在后面:2 3 4 1 6 5,那么反过来的5 6 1 4原创 2015-08-17 21:16:48 · 373 阅读 · 0 评论 -
POJ 2367 Genealogical tree (拓扑排序)
POJ 2367 Genealogical tree (拓扑排序) The system of Martians' blood relations is confusing enough. Actually, Martians bud when they want and where they want. They gather together in different groups, so that a Martian can have one parent as well as ten. Nob原创 2015-08-18 10:27:30 · 397 阅读 · 0 评论 -
HDOJ 1159(POJ 1458)Common Subsequence (最长公共子序列 LCS)
最大公共子序列长度 (LCS)Common Subsequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 28498 Accepted Submission(s): 12738 Problem Description A subsequence of a given sequence is the given sequenc原创 2015-08-10 13:25:08 · 456 阅读 · 0 评论 -
HDOJ 1301 Jungle Roads 最小生成树 kruskal && prim
Jungle Roads 说明:求最小生成树(用 克鲁斯卡尔) 题目大意: 在相通n个岛屿的所有桥都坏了,要重修, 重修每一个桥所用的时间不同,求重修使每个岛屿都间接或直接与其他岛屿相同时所用的的最短时间(只有修完一个桥后才可修下一个桥)。------------求最小生成树。 数据: 数据输入的第一行n代表岛屿的个数,当为0是结束程序,接着n-1行开始时为这岛屿的编号,用大写字母表示,接着是一个整数 m,表示与该岛屿连接的字典序大于该岛屿编号的个数,然后该行输入原创 2015-08-11 17:52:18 · 384 阅读 · 0 评论 -
POJ 3253 Fence Repair (优先队列)
Fence Repair Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 32431 Accepted: 10420 Description Farmer John wants to repair a small length of the fence ar原创 2015-08-06 13:23:01 · 483 阅读 · 0 评论 -
POJ 2406 Power Strings (KMP)
KMP 模板 Power Strings Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 37668 Accepted: 15580 Description Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we thi原创 2015-08-10 14:09:37 · 272 阅读 · 0 评论 -
POJ 2752 Seek the Name, Seek the Fame (KMP)
(KMP 模板)给一个字符串S, 求出所有前缀pre,使得这个前缀也正好是S的后缀。 输出所有前缀的结束位置。Seek the Name, Seek the Fame Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 14185 Accepted: 7066 Description The little cat is so famous, that many couples tramp over hill and dale to原创 2015-08-10 14:03:56 · 384 阅读 · 0 评论 -
POJ 2349 Arctic Network 最小生成树 prim && kruscal
Arctic Network 克鲁斯卡尔(kruscal)或普里姆算法(Prim) 求最小生成树。 Arctic Network Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 13208 Accepted: 4284 Description The Department of National Defence (DND) wishes to connect several northern outposts by a w原创 2015-08-12 21:36:36 · 527 阅读 · 0 评论 -
POJ 1258 Agri-Net 最小生成树 prim && kruskal
Agri-Net 最小生成树 Agri-Net Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 45228 Accepted: 18575 Description Farmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms原创 2015-08-12 16:09:24 · 548 阅读 · 0 评论 -
POJ 2485 Highways 最小生成树 Kruskal && Prim
Highways 求最小生成树的最大边 The island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has no public highways. So the traffic is difficult in Flatopia. The Flatopian government is aware of this problem. They're planning to build some highways原创 2015-08-13 19:12:50 · 431 阅读 · 0 评论