
ACM_图论
文章平均质量分 77
HQD因为有趣所以做题
这个作者很懒,什么都没留下…
展开
-
2003: Currency Table
这道题目很无语,首先是输入,最后采取的输入方法是读入一个数,就把对应的那个数算出来。接着不管读入的是什么也不会影响到。接着这道题目用的竟然是FLOYED,但这个算法是经过改变,不需要讨论所有的,只有那种事0的外面才算的,好像是这样,但这道题目我觉得还是有歧义的。 StatusIn/OutTIME LimitMEMORY LimitSubmit T原创 2010-03-04 15:07:00 · 709 阅读 · 0 评论 -
JOJ 1198: Risk
StatusIn/OutTIME LimitMEMORY LimitSubmit TimesSolved UsersJUDGE TYPEstdin/stdout3s8192K322183StandardRisk is a board game in whic原创 2010-03-10 17:49:00 · 596 阅读 · 0 评论 -
拓扑排序 JOJ 2237: Hero Ranklist
StatusIn/OutTIME LimitMEMORY LimitSubmit TimesSolved UsersJUDGE TYPEstdin/stdout5s8192K228103StandardArthur想要将手下的战士按照能力进行排名, 选择出得力的助手进行冒险. 他收集了很多人之间比武的胜负情况,如A战原创 2010-03-12 08:28:00 · 647 阅读 · 0 评论 -
JOJ 1170: Wire Is So Expensive
最小生成树。StatusIn/OutTIME LimitMEMORY LimitSubmit TimesSolved UsersJUDGE TYPEstdin/stdout3s8192K551233Standard1st Jilin University ACM原创 2010-03-12 08:53:00 · 499 阅读 · 1 评论 -
再探拓扑排序JOJ 2237 Hero Ranklist
#include#includeint m,n;int map[20][20],degree[20];char s[20],list[20];bool visit[20];void dfs(int depth){ int i,j; if(depth>=m) { list[depth]=0; printf("%s/n",list); return; } for(i=1;i if(degree原创 2010-03-12 09:50:00 · 468 阅读 · 0 评论 -
迪杰斯特拉代码
const int maxn=605;const int inf=8000000;void dij(int n,int g[][maxn],int s,int d[]){ int i,r; int minc,used[n]; for(i=0;i { d[i]=inf;used[i]=0; } d[s]=0; for(int k=0;k { minc=inf; for(i=0;i if原创 2010-03-12 11:57:00 · 748 阅读 · 0 评论 -
SPFA算法
求单源最短路的SPFA算法的全称是:Shortest Path Faster Algorithm。 SPFA算法是西南交通大学段凡丁于1994年发表的. 从名字我们就可以看出,这种算法在效率上一定有过人之处。 很多时候,给定的图存在负权边,这时类似Dijkstra等算法便没有了用武之地,而Bellman-Ford算法的复杂度又过高,SPFA算法便派上用场了。 简洁起见,转载 2010-04-01 21:06:00 · 2309 阅读 · 0 评论 -
A Pair of Graphs(图的构造) HDU 2464
A Pair of GraphsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 357 Accepted Submission(s): 184Problem DescriptionWe say that two graph原创 2010-04-05 19:34:00 · 1058 阅读 · 0 评论 -
POJ Frogger
<br />Frogger<br />Time Limit: 1000 ms Case Time Limit: 1000 ms Memory Limit: 65535 KB<br />Submit: 138 Accepted: 46Description<br /><br />一只叫Freddy的青蛙蹲坐在湖中的一块石头上。突然他发现一只叫Fiona的青蛙在湖中的另一块石头上。Freddy想要跟Fiona约会,但由于湖水太脏,他不想游泳过去而是跳过去找Fiona。<br />很不幸,原创 2010-07-12 21:18:00 · 1617 阅读 · 0 评论 -
HNU ACM: Cheering up the Cows (kruscal)
B: Cheering up the Cows<br />Time Limit: 1000 ms Case Time Limit: 1000 ms Memory Limit: 65536 KB<br />Submit: 13 Accepted: 8 <br />Description<br /><br />Farmer John has grown so lazy that he no longer wants to continue maintaining the cow path原创 2010-07-12 21:40:00 · 971 阅读 · 0 评论 -
2367 史上最水的拓排 Genealogical tree
<br />Genealogical treeTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 815 Accepted: 578 Special Judge<br />DescriptionThe system of Martians' blood relations is confusing enough. Actually, Martians bud when they want and where they want. They ga原创 2010-07-15 17:00:00 · 526 阅读 · 0 评论 -
poj 2552 JOJ 2083 The Bottom of a Graph 图的强连通性
<br /><br />The Bottom of a GraphTime Limit: 3000MS Memory Limit: 65536KTotal Submissions: 3066 Accepted: 1227<br />DescriptionWe will use the following (standard) definitions from graph theory. Let V be a nonempty and finite set, its elements being ca原创 2010-07-19 16:35:00 · 695 阅读 · 0 评论 -
2186 Popular Cows 图的连通性
<br /><br />Popular CowsTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 9234 Accepted: 3690<br />DescriptionEvery cow's dream is to become the most popular cow in the herd. In a herd of N (1 <= N <= 10,000) cows, you are given up to M (1 <= M原创 2010-07-19 15:11:00 · 660 阅读 · 0 评论 -
HDU2767 Proving Equivalences 图的强联通性
<br />Proving EquivalencesTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)<br />Total Submission(s): 205 Accepted Submission(s): 89<br /><br /><br />Problem DescriptionConsider the following exercise, found in a generi原创 2010-07-18 22:39:00 · 976 阅读 · 0 评论 -
1236 Network of Schools 图的强连通性
<br /><br />Network of SchoolsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 3010 Accepted: 1160<br />DescriptionA number of schools are connected to a computer network. Agreements have been developed among those schools: each school maintai原创 2010-07-19 09:59:00 · 745 阅读 · 0 评论 -
World Islands HDU3405 杭州省赛 最小生成树
World Islands<br />Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)<br />Total Submission(s): 206 Accepted Submission(s): 78<br /><br />Problem DescriptionDubai is a haven for the rich. The government of Dubai finds a原创 2010-07-31 08:55:00 · 1931 阅读 · 0 评论 -
差分约束系统(System Of Difference Constraints)
差分约束系统(System Of Difference Constraints)(本文假设读者已经有以下知识:最短路径的基本性质、Bellman-Ford算法。) 比如有这样一组不等式: X1 - X2 X1 - X5 X2 - X5 X3 - X1 X4 - X1 X4 - X3 X5 - X3 X5 - X4 全都是两个未知数的差小于等于某个常数(大于等于也可以,因为左右乘以-1就可以化成小于等于)。这样的不等式组就称作差分约束系统。 这个不等式组要么无解,转载 2010-08-11 11:38:00 · 445 阅读 · 0 评论 -
1201 Intervals 差分约束系统
鄙人第一个差分约束系统。看了N多的资料和别人的解题报告,发现下面用BELLMAN FORD 加稍微的剪枝时间可以飙到200MS以内,不错不错。就是那个FLAG,没了这个就TLE了。。。惨剧啊!!!!另外的话,这个题目的例子是给了5个区间,说5个区间包含了Z数组C个数,接着问你Z数组到底至少有几个数。数组不用连续主要是下面三点1。s[b]>=s[a-1]+c2.s[b-1]>=s[b]+(-1)3.s[b]>=s[b-1]维护这三个不等式即可,s[]表示从0到x含有的数字的个数如何维护呢?想像一下做图论的时候原创 2010-08-11 14:39:00 · 709 阅读 · 0 评论 -
SPFA算法
SPFA算法为了简便,我们约定图中不存在负权回路,这可以通过一次拓扑排序知道。SPFA实际是Bellman-Ford算法的一种队列实现,用一个数组来保存最短路径的估计值,初始时将源加入队列,每次从队列中取队头元素,并对所有与其相邻的结点进行松弛操作,如果该点的估计值有所调整,且该点不在队列中,则入队,如此反复,直到队空。定理1:SPFA算法采用的动态优化方法,能够使得路径估计值变得越来越小,优化过程是正确的。证明:算法中每一步都是从该队取出点来优化其它各点。现假设算法结束时计算的结果不是最短路径,即从原点到转载 2010-08-11 14:49:00 · 1322 阅读 · 0 评论 -
最短路径——SPFA
<br /><br />Posted on 2009-10-30 14:00 小强摩羯座 阅读(350) 评论(0) 编辑 收藏 所属分类: 算法编程 <br />最短路径 之 SPFA算法 (转载)(2009-05-06 20:41:51)<br />标签:spfa 杂谈 <br />求最短路径的算法有许多种,除了排序外,恐怕是OI界中解决同一类问题算法最多的了。最熟悉的无疑是Dijkstra,接着是Bellman-Ford,它们都可以求出由一个源点向其他各点的最短路径;如果我们想要求出每一对顶点转载 2010-08-11 15:24:00 · 3066 阅读 · 0 评论 -
3159 Candies SPFA
<br /><br />CandiesTime Limit: 1500MS Memory Limit: 131072KTotal Submissions: 12484 Accepted: 3226<br />Description<br />During the kindergarten days, flymouse was the monitor of his class. Occasionally the head-teacher brought the kids of flymouse’s cla原创 2010-08-11 20:06:00 · 515 阅读 · 0 评论 -
3169 Layout 差分约束系统
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 2066 Accepted: 993DescriptionLike everyone else, cows like to stand close to their friends when queuing for feed. FJ has N (2原创 2010-08-12 09:46:00 · 513 阅读 · 0 评论 -
1201 Intervals SPFA
我自己的程序#include#includeconst int E=50005;const int V=50005;const int INF=1struct EDGE{ int link,val,next;}edge[E*3];int head[V],dist[V],q[E*3],e,rmin,rmax;bool vis[V];void addedge(int a,int b,int c){ edge[e].link=b; edge[e].val=c; edge[e].next=h原创 2010-08-12 13:37:00 · 525 阅读 · 1 评论 -
1275 Cashier Employment 差分约束系统+BELLMAN
<br />Cashier EmploymentTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 3409 Accepted: 1211<br />DescriptionA supermarket in Tehran is open 24 hours a day every day and needs a number of cashiers to fit its need. The supermarket manager has h原创 2010-08-12 16:32:00 · 625 阅读 · 0 评论 -
1364 King BELLMAN(最长路 最短路)
<br /><br />KingTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 4080 Accepted: 1630<br />DescriptionOnce, in one kingdom, there was a queen and that queen was expecting a baby. The queen prayed: ``If my child was a son and if only he was a so原创 2010-08-13 10:27:00 · 608 阅读 · 0 评论 -
1364 King SPFA
KingTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 4087 Accepted: 1633<br />DescriptionOnce, in one kingdom, there was a queen and that queen was expecting a baby. The queen prayed: ``If my child was a son and if only he was a sound king.'' Afte原创 2010-08-13 11:09:00 · 488 阅读 · 0 评论 -
1716 Integer Intervals
Integer IntervalsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 7404 Accepted: 2991<br />DescriptionAn integer interval [a,b], a < b, is a set of all consecutive integers beginning with a and ending with b. <br />Write a program that: finds the原创 2010-08-13 11:24:00 · 649 阅读 · 0 评论 -
2239 Selecting Courses 二分图匹配
<br /><br />Selecting CoursesTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 4638 Accepted: 2009<br />DescriptionIt is well known that it is not easy to select courses in the college, for there is usually conflict among the time of the courses.原创 2010-08-13 15:14:00 · 737 阅读 · 0 评论 -
1325 Machine Schedule //MaxMatch
<br /><br />Machine ScheduleTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 5816 Accepted: 2425<br />DescriptionAs we all know, machine scheduling is a very classical problem in computer science and has been studied for a very long history. S原创 2010-08-14 09:20:00 · 513 阅读 · 1 评论 -
二分图最大(基数)匹配以及与其等价的几个问题
一.最大独立点集的定义给定无向图G(V,E),其中A为顶点集合V的子集,且E∩{(i,j) | i,j∈A}=空集.求A,使得|A|最大二.最小顶点覆盖集的定义给定无向图G(V,E),一个顶点覆盖集(vertex covering)是指顶点集S(S为V的子集),使得G中任一条边(x,y)至少有一端点在S中.求S,使得|S|最小三.最大完全子图的定义给定无向图G(V,E),其中C为顶点集合V的子集,对于任意两个点i,j∈C,且i≠j,有(i,j)∈E.求C,使得|C|最大四.三者的等价性(1)最大独立点集与最转载 2010-08-13 15:54:00 · 1462 阅读 · 0 评论 -
二分图(匈牙利算法)
<br />什么是二分图,什么是二分图的最大匹配,这些定义我就不讲了,网上随便都找得到。二分图的最大匹配有两种求法,第 一种是最大流(我在此假设读者已有网络流的知识);第二种就是我现在要讲的匈牙利算法。这个算法说白了就是最大流的算法,但是它跟据二分图匹配这个问题的 特点,把最大流算法做了简化,提高了效率。匈牙利算法其实很简单,但是网上搜不到什么说得清楚的文章。所以我决定要写一下。<br />最大流算法的核心问题就是找增广路径(augment path)。匈牙利算法也不例外,它的基本模式就是:<br /><b转载 2010-08-13 16:09:00 · 720 阅读 · 0 评论 -
二分图最大匹配的König定理及其证明
<br />转自Matrix67神牛<br /> <br /> <br />如果你看不清楚第二个字母,下面有一个大号字体版本:<br /><br />二分图最大匹配的König定理及其证明<br /><br /> 本文将是这一系列里最短的一篇,因为我只打算把König定理证了,其它的废话一概没有。<br /> 以下五个问题我可能会在以后的文章里说,如果你现在很想知道的话,网上去找找答案:<br /> 1. 什么是二分图;<br /> 2. 什么是二分图的匹配;<br /> 3.转载 2010-08-13 16:23:00 · 603 阅读 · 0 评论 -
3041 Asteroids //MaxMatch
<br /><br />AsteroidsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 5980 Accepted: 3091<br />DescriptionBessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 <= N <= 500). The grid contain原创 2010-08-13 16:27:00 · 525 阅读 · 1 评论 -
Maigo的KM算法讲解
<br />KM算法是通过给每个顶点一个标号(叫做顶标)来把求最大权匹配的问题转化为求完备匹配的问题的。设顶点Xi的顶标为A[i],顶点Yi的顶标为B[i],顶点Xi与Yj之间的边权为w[i,j]。在算法执行过程中的任一时刻,对于任一条边(i,j),A[i]+B[j]>=w[i,j]始终成立。KM算法的正确性基于以下定理:<br />若由二分图中所有满足A[i]+B[j]=w[i,j]的边(i,j)构成的子图(称做相等子图)有完备匹配,那么这个完备匹配就是二分图的最大权匹配。<br /> 这个定理是显然的转载 2010-08-14 10:59:00 · 728 阅读 · 0 评论 -
2536 Gopher II
<br /><br />Gopher IITime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 3494 Accepted: 1461<br />DescriptionThe gopher family, having averted the canine threat, must face a new predator. <br /><br />The are n gophers and m gopher holes, each at dist原创 2010-08-19 21:34:00 · 769 阅读 · 0 评论 -
最小路径覆盖
<br />最小路径覆盖<br /> 在一个PXP的有向图中,路径覆盖就是在图中找一些路经,使之覆盖了图中的所有顶点,且任何一个顶点有且只有一条路径与之关联;(如果把这些路径中的每条路径从它的起始点走到它的终点,那么恰好可以经过图中的每个顶点一次且仅一次);如果不考虑图中存在回路,那么每每条路径就是一个弱连通子集. 由上面可以得出: 1.一个单独的顶点是一条路径; 2.如果存在一路径p1,p2,......pk,其中p1 为起点,pk为终点,那么在覆盖图中,顶点p1,p2,......pk不再与其它原创 2010-08-20 20:01:00 · 591 阅读 · 0 评论 -
1422 Air Raid //MAXMATCH
<br /><br /> Air RaidTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 3329 Accepted: 1946<br />DescriptionConsider a town where all the streets are one-way and each street leads from one intersection to another. It is also known that starting f原创 2010-08-20 20:28:00 · 673 阅读 · 0 评论 -
2771 Guardian of Decency //MaxMatch
Guardian of DecencyTime Limit: 3000MS Memory Limit: 65536KTotal Submissions: 3126 Accepted: 1308DescriptionFrank N. Stein is a very conservative high-school teacher. He wants to take some of his students on an excursion, but he is afraid that some of t原创 2010-08-20 21:56:00 · 809 阅读 · 0 评论 -
3189 Steady Cow Assignment //MaxMatch
<br />Steady Cow AssignmentTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 2134 Accepted: 730<br />DescriptionFarmer John's N (1 <= N <= 1000) cows each reside in one of B (1 <= B <= 20) barns which, of course, have limited capacity. Some cows re原创 2010-08-21 11:13:00 · 639 阅读 · 0 评论 -
KM算法总结
<br /><br />【二分图】二分图是一种特殊的图结构,所有点分为两类,记做x和y,所有的边的两端分别在x和y,不存在两端同在x或y的边。<br /> <br />【最大匹配、完备匹配】<br />给定一个二分图(x,y),找到一种匹配数最大的方案,记做最大匹配。|x|=|y|=匹配数时,我们称该匹配方案为完备匹配。<br />显然,解决了最大匹配也就解决了完备匹配。<br />解决二分图的最大匹配可以用网络流或者匈牙利算法,两者本质上是相同的,不过不论从编程复杂度还是运行效率来讲,匈牙利算法都更加优秀原创 2010-08-22 09:41:00 · 9011 阅读 · 0 评论