题意 给你张无环有向图,问至少多少条路径能够覆盖该图的所有顶点--并且,这些路径可以有交叉. 思路 不是裸的最小路径覆盖,正常的最小路径覆盖中两个人走的路径不能有重复的点,而本题可以重复. 当然我们仍可将问题转化为最小路径覆盖.如果一个人需要经过另一个人走过的点的时候,让他直接从该点上空飞过去,越过该点,直接走下一个点.如果我们赋予每个人这种能力,那么求得的无重复点的最小路径覆盖结果,就是题目要求的结果,因为需要重复的地方只要飞过去,就可以不重复了.赋予这个能力的方法就是预处理用Floyd求传递…
Treasure Exploration Time Limit: 6000MS   Memory Limit: 65536K Total Submissions: 9794   Accepted: 3975 题目链接:http://poj.org/problem?id=2594 Description: Have you ever read any book about treasure exploration? Have you ever see any film about treasure…
                                             Treasure Exploration 复见此题,时隔久远,已忘,悲矣! 题意:用最少的机器人沿单向边走完(覆盖)全部的点.典型的最小路径覆盖,如果不懂二分图匹配可以参考:二分图大讲堂 先用floyd传递闭包,再求最大匹配,最小路径覆盖=V-最大二分匹配(最小点覆盖).为什么要用floyd传递闭包呢,每个点可以被多个机器人走过,博主就是这里没考虑到.. 我记得这个题是写过博客的....//领接矩阵匈牙利算…
Treasure Exploration Time Limit: 6000MS   Memory Limit: 65536K Total Submissions: 8130   Accepted: 3325 Description Have you ever read any book about treasure exploration? Have you ever see any film about treasure exploration? Have you ever explored…
POJ 2594 Treasure Exploration 题目链接 题意:有向无环图,求最少多少条路径能够覆盖整个图,点能够反复走 思路:和普通的最小路径覆盖不同的是,点能够反复走,那么事实上仅仅要在多一步.利用floyd求出传递闭包.然后依据这个新的图去做最小路径覆盖就可以 代码: #include <cstdio> #include <cstring> #include <vector> #include <algorithm> using names…
题目链接: Poj 2594 Treasure Exploration 题目描述: 在外星上有n个点需要机器人去探险,有m条单向路径.问至少需要几个机器人才能遍历完所有的点,一个点可以被多个机器人经过. 解题思路: 一眼看上去是普通的最小边覆盖,但是仔细想后发现如果在原图上进行最大匹配的话,每个点只能经过一次.这样的话对于本题求出的并不是最优解,所以我们要先对原图进行传递闭包处理,然后再进行最大匹配. 这个题目点数太少H_K和匈牙利算法在空间和时间上并没有什么差,就代码复杂度而言匈牙利算法更有优…
Treasure Exploration Time Limit: 6000MS   Memory Limit: 65536K Total Submissions: 6558   Accepted: 2644 Description Have you ever read any book about treasure exploration? Have you ever see any film about treasure exploration? Have you ever explored…
http://poj.org/problem?id=2594 Treasure Exploration Time Limit: 6000MS   Memory Limit: 65536K Total Submissions: 7398   Accepted: 3025 Description Have you ever read any book about treasure exploration? Have you ever see any film about treasure explo…
Treasure Exploration Time Limit:6000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 2594 Description Have you ever read any book about treasure exploration? Have you ever see any film about treasure exploratio…
最小路径覆盖 DAG的最小可相交路径覆盖: 算法:先用floyd求出原图的传递闭包,即如果a到b有路径,那么就加边a->b.然后就转化成了最小不相交路径覆盖问题. 这里解释一下floyd的作用如果1->2->3->4那么1可以到达2,3,4只要需要借助一些点,那么就可以直接把1与2,3,4相连,这就是floyd要做的事. 证明:为了连通两个点,某条路径可能经过其它路径的中间点.比如1->3->4,2->4->5.但是如果两个点a和b是连通的,只不过中间需要经…
题意:选出最小路径覆盖图中所有点,路径可以交叉,也就是允许路径有重复的点. 分析:这个题的难点在于如何解决有重复点的问题-方法就是使用Floyd求闭包,就是把间接相连的点直接连上边,然后就是求最小路径覆盖了.我来大概解释一下为什么是对的,首先我们要明确,当我们重复利用一个点的时候,一定是有两个比较良好的路径相交了,而二分图是不允许这样的情况存在的,因为那必然存在了一个点有一个以上的出度或者入度了,而怎么避免这个问题呢,看下面的图: 这就是针对这个问题的一个典型的模型,如果使用正常二分图,求得的匹…
题意:  派机器人去火星寻宝,给出一个无环的有向图,机器人可以降落在任何一个点上,再沿着路去其他点探索,我们的任务是计算至少派多少机器人就可以访问到所有的点.有的点可以重复去. 输入数据: 首先是n和m, 代表有n个顶点, m条边.(m和n同时为0时则输入数据结束) 接下来m行,每行两个数字 a, b代表 从a到b可以通行. 题目分析: 这道题目与最小路径有一点差别,最小路径覆盖上是不存在交叉路的,但是这个题目是存在交叉路的. 对于交叉路的处理我们可以使用Floyd闭包传递.即 i->j, j-…
<题目链接> 题目大意: 机器人探索宝藏,有N个点,M条边.问你要几个机器人才能遍历所有的点. 解题分析: 刚开始还以为是最小路径覆盖的模板题,但是后面才知道,本题允许一个点经过多次,这与最小路径覆盖中,路径之间不能有交点重合相矛盾,所以,我们用Floyd利用传递闭包对原图进行一些处理.所谓传递闭包就是,a能到b,b能到c,所以a能到c.最后对处理后的图计算最小路径覆盖. #include <cstdio> #include <cstring> #include <…
一个星球上有很多点,点与点之间有很多单向路 问可重点的最小路径覆盖 利用floyd缩点后求二分图最大匹配 #include <iostream> #include <cstdio> #include <cstring> using namespace std; ; int m,n; int map[maxn][maxn]; int link[maxn],vis[maxn]; void floyd() { int i,j,k; ;k<=n;k++) ;i<=n…
传送门:http://poj.org/problem?id=2060 Taxi Cab Scheme Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 7260 Accepted: 2972 Description Running a taxi station is not all that simple. Apart from the obvious demand for a centralised coordination…
点击打开链接题目链接 Treasure Exploration Time Limit: 6000MS   Memory Limit: 65536K Total Submissions: 7215   Accepted: 2947 Description Have you ever read any book about treasure exploration? Have you ever see any film about treasure exploration? Have you eve…
题意:有n个点,m条单向边,每个机器人能沿着单向边走,能重复经过一个点,问最少几个机器人走遍n个点 思路:原来以前学的都是不能相交的算法....可相交的做法是跑Floyd把能到达的都加上边,然后跑最小覆盖 代码: #include<set> #include<map> #include<stack> #include<cmath> #include<queue> #include<vector> #include<string&…
题目链接:http://poj.org/problem?id=2594 思路:本来求最小路径覆盖是不能相交的,那么对于那些本来就可达的点怎么处理,我们可以求一次传递闭包,相当于是加边,这样我们就可以来求最小路径覆盖了.最小路径覆盖=顶点数-最大匹配.http://www.cnblogs.com/ka200812/archive/2011/07/31/2122641.html http://paste.ubuntu.com/5943395/…
DAG图上可相交最小路径覆盖 先求给定DAG的传递闭包,将任意相连的两点加入二分图中,然后就是经典的不相交最小路径覆盖 所谓传递闭包就是将DAG图中任意点间的连通关系处理出来,用Floyd即可 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cstdlib> using namespace std; int init()…
Have you ever read any book about treasure exploration? Have you ever see any film about treasure exploration? Have you ever explored treasure? If you never have such experiences, you would never know what fun treasure exploring brings to you.Recentl…
题意:给一个有向无环图,求出来最小路径覆盖,注意一个点可能会被多条路径重复 分析:因为有可能多条路径走一个点,可又能会造成匹配的不完全,所以先进行一次闭包传递(floyd),然后再用二分匹配的方法求出来最大匹配即可. *********************************************************************. #include<stdio.h> #include<; ; ; k<=N; k++)     ; i<=N; i++)…
题目链接:http://poj.org/problem?id=2594 Treasure Exploration Time Limit: 6000MS   Memory Limit: 65536K Total Submissions:10480   Accepted: 4250 Description Have you ever read any book about treasure exploration? Have you ever see any film about treasure…
传送门:http://poj.org/problem?id=2594 Treasure Exploration Time Limit: 6000MS   Memory Limit: 65536K Total Submissions: 9802   Accepted: 3979 Description Have you ever read any book about treasure exploration? Have you ever see any film about treasure e…
Treasure Exploration Time Limit: 6000MS   Memory Limit: 65536K Total Submissions: 7171   Accepted: 2930 Description Have you ever read any book about treasure exploration? Have you ever see any film about treasure exploration? Have you ever explored…
Treasure Exploration Time Limit: 6000MS   Memory Limit: 65536K Total Submissions: 8550   Accepted: 3495 Description Have you ever read any book about treasure exploration? Have you ever see any film about treasure exploration? Have you ever explored…
Treasure Exploration Have you ever read any book about treasure exploration? Have you ever see any film about treasure exploration? Have you ever explored treasure? If you never have such experiences, you would never know what fun treasure exploring…
题目链接:https://vjudge.net/problem/POJ-2594 Treasure Exploration Time Limit: 6000MS   Memory Limit: 65536K Total Submissions: 9005   Accepted: 3680 Description Have you ever read any book about treasure exploration? Have you ever see any film about trea…
题目链接:http://poj.org/problem?id=2594 在外星上有n个点需要机器人去探险,有m条单向路径.问至少需要几个机器人才能遍历完所有的点,一个点可以被多个机器人经过(这就是和单纯的最小路径覆盖的区别). 因为图是一个有向图 例如 1—>3, 2—>3; 3—>4; 3—>5; 左边是floyd之前的,右边是传递之后的,左边的最大匹配是2,右边是3: 其中为什么用传递闭包就能求最大匹配,自己只可意会不可言传:—_—;   #include<stdio.h…
题目链接:http://lightoj.com/volume_showproblem.php?problem=1429 思路:这道题还是比较麻烦的,对于求有向图的可相交的最小路径覆盖,首先要解决成环问题,可以先染色缩点重建图,然后就是如何来处理这个路径可以相交这个问题,这里可以用bfs求出任意两点之间是否可达,如果可达,就连边,然后就是HK算法求最大匹配了,最小路径覆盖 = 顶点数 - 最大匹配. #include <iostream> #include <cstdio> #inc…
Repairing Company Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 6646   Accepted: 1788 Description Lily runs a repairing company that services the Q blocks in the city. One day the company receives M repair tasks, the ith of which occu…