2012年7月3日

poj 2553 The Bottom of a Graph

摘要: http://poj.org/problem?id=2553题意:给一个无向图,如果一个点v能够到达w并且w也能到v则w和v都称为一个sink,题目要求从大到小输出图中所有的sink点。注意叶子结点都是sink点。思路:正如上面说的叶子结点都是sink,而且只有叶子结点才能形成sink点。因而先进行缩点,然后再求叶子结点。View Code #include<set>#include<map>#include<stack>#include<queue>#include<cmath>#include<bitset>#incl 阅读全文

posted @ 2012-07-03 21:51 aigoruan 阅读(114) 评论(0) 推荐(0)

poj 1523 SPF

摘要: http://poj.org/problem?id=1523题目大意:给定一个图,求这个图的割点,以及把该割点去掉以后的图有多少过连通分量。思路:先求出所有的割点,然后暴力枚举这些割点求连通分量(1000个点)。View Code #include<set>#include<map>#include<stack>#include<queue>#include<cmath>#include<bitset>#include<string>#include<climits>#include<cstd 阅读全文

posted @ 2012-07-03 20:39 aigoruan 阅读(148) 评论(0) 推荐(0)

hdu 3394 Railway

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3394题意:给定一个有N个点,M条边的无向图,求有多少条边没有在环内,有多少条边在至少2个环内。思路:画一下图,很容易就想到在一个双连通图里,如果边数>点数,则此双连通图里的边都是在2个环内的。其实是错的,下面数据就是这样的特例:6 61 21 32 33 43 54 5其中3为割点。主要就是处理这种数据,在tarjan中,u是v的父亲,从v回溯到u,如果low[v]>dfn[u],则说明v到u没有环,如果low[v]==dfn[u],则说明u到v有环;这两种情况都要处理。View Code #i 阅读全文

posted @ 2012-07-03 17:01 aigoruan 阅读(192) 评论(0) 推荐(0)

hdu 3639 Hawk-and-Chicken

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3639题意:给一个无向图,求出拥有最多祖父的节点。思路:先tarjan缩点,可以知道只能出现在叶子节点,所以反向建图,对每个入度为0的节点进行遍历统计。View Code #include<stdio.h>#include<string.h>#include<iostream>#include<algorithm>#include<bitset>#include<stack>#include<utility>using nam 阅读全文

posted @ 2012-07-03 10:20 aigoruan 阅读(156) 评论(0) 推荐(0)

导航