![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
图论
文章平均质量分 78
Vgo__
这个作者很懒,什么都没留下…
展开
-
poj 2553 (tarjan的应用)
<br />趁着刚学这个算法,就连续刷刷。。。掌握才是关键。。。<br />这个题刚开始怎么也看不懂,后来在discuss里看到网友们有说“if for every node w in G that is reachable from v, v is also reachable from w.”这句很重要的时候 ,豁然开朗呀。。。只怪自己没怎么认真看题呀<br /> <br />/* * 关于sink:如果v可以到达w,那么w一定要能到达v;如果到不了,也是可以的。 * 这就是那原创 2011-05-15 21:46:00 · 325 阅读 · 0 评论 -
poj 2983 (spfa写的查分约束)
刚开始的时候,没想到怎么设置源点,wa了几次,后来看到有用0点做源点的,试了一下,AC!!!#include using namespace std;const int Max=100002;struct node{ int v,c,next;}edge[Max*3];int edgehead[1002],vis[1002],dis[1002],k=0;int q[Max],head=0,rear=0;int cnt[1002];void addedge(int u原创 2011-05-18 16:56:00 · 531 阅读 · 0 评论 -
poj 1201(spfa)
<br />看到一篇文章介绍查分约束系统的http://imlazy.ycool.com/post.1702305.html 讲的特别好,然后想起很早以前看到过的这个题,做了一下,AC!!!<br /> <br /> 简单说一下我的理解: 对这个题来说,就是找到足够多的约束条件,然后根据条件,运用spfa找最长路就可以了,好像差分约束系统就是一个条件比较多的最短路(或者最长路),这个题的条件有【i , i】=0;【i+1 ,i 】= -1;dis【v】>=dis[u]+maze[u].len; 以及原创 2011-05-17 20:20:00 · 446 阅读 · 0 评论 -
poj 3020(匈牙利算法的简单应用,关键是构图)
<br />貌似临接矩阵也是可以的,不过习惯用临接表了,直接用的临接表。。。。。<br />构图的时候为了避免边的覆盖,选择 i * m + j 这种方式(看题解的时候看到的,刚开始自己直接来构图,WA) 之后就是简单的匈牙利算法。。。。刚学会。。。看到非递归的那个代码长度。。。。直接递归了。。。。<br /> <br />上代码:<br />#include <iostream>#include<cstdio>#include<cstring>using namespace std;s原创 2011-05-28 21:06:00 · 612 阅读 · 0 评论 -
poj 3041(匈牙利)
<br />这个没什么好说的。。。懂这个算法救知道。。这个水题很简单了。。。。<br /> <br />#include <iostream>#include <cstring>#include <cstdio>using namespace std;const int maxlen=505;int maze[maxlen][maxlen],match[maxlen];bool vis[maxlen];int crosspath(int x){ int i,k;原创 2011-05-28 21:10:00 · 391 阅读 · 0 评论 -
poj 3352(无向图的双连通分量)
刚开始的时候习惯性的套用了以前的代码------有向图的 tarjan 算法, WA。。。。。意识到无向图的双连通和有向图的强连通是不能互换的,想搜一些讲解来看看,找不到好的资料,只好自己把tarjan算法的原理好好看以了一遍,然后在这个算法的基础上,加以改变,来算出双连通分量,然后关于割点的处理可以参考这个博客的讲解,http://www.byvoid.com/blog/biconnec原创 2011-06-03 15:49:00 · 1083 阅读 · 0 评论 -
poj 3177(万恶的双连通)
之前写那个3352的时候,自己写了一个双连通算法,可用在这里,无限WA。。。。重边问题呀。。。这个题解决了重边问题,就可以应用双连通算法简单写出来了,题解可以参考3352那个题的解题讲解。。。(这个双连通算法是看了刘汝佳的黑书写出来的,唉。。。) #include #include #include #include #include using namespace原创 2011-06-04 21:32:00 · 486 阅读 · 0 评论 -
poj 3102(暴力枚举)
很水。。。看了别人的题解之后,也用了暴力。。。 #include#include#include#includeusing namespace std;const double inf=1e15;const double e=1e-6;int x[210],y[210];double maze[210][210];double dis(int i,int原创 2011-06-05 13:17:00 · 844 阅读 · 0 评论