2012年6月27日

poj 2186 Popular Cows

摘要: http://poj.org/problem?id=2186题意:若A认为B好,且B又认为C好,则可以推出A认为C好,现给一个这样的无向关系图,求出有多少个点,所有人都认为它好。思路:先对图进行tarjan去环缩边成点,并统计环中点的个数,然后查看一下出度为0的点是否为1,如果是则这个点代表的环里的点的数目,否则puts("0");View Code #include<stdio.h>#include<string.h>#include<iostream>#include<stack>#include<utility&g 阅读全文

posted @ 2012-06-27 21:18 aigoruan 阅读(133) 评论(0) 推荐(0)

poj 1236 Network of Schools

摘要: http://poj.org/problem?id=1236题意:1.要求出至少发分配多少站点,使所有点都能收到,即求入度为0的分量。 2.求要添加多少点,使任意一个点发送物品,其他点都能收到物品,即求Max(入度为0的分量个数,出度为0的分量个数)。注意单点的情况.View Code #include<string.h>#include<stdio.h>#include<iostream>#include<stack>#include<utility>using namespace std;const int maxn = 105; 阅读全文

posted @ 2012-06-27 19:53 aigoruan 阅读(123) 评论(0) 推荐(0)

poj 2762

摘要: http://poj.org/problem?id=2762题意:给一个无向图,问对任意的两个点x,y,是否都存在一条路径从一个点出发到达另一个点。思路:先用tarjan对无向图进行缩边和求弱连通分量,如果弱连通分量不为1,则No;然后重建无向图,判断是否是线树,是则Yes,否则No。注意:缩边后的图不一定是棵标准的树。View Code #include<stdio.h>#include<string.h>#include<stdlib.h>#include<iostream>#include<stack>#include<u 阅读全文

posted @ 2012-06-27 19:09 aigoruan 阅读(137) 评论(0) 推荐(0)

导航