摘要: 题意:给定一个网络,每条线路都同时有几个公式拥有,现在问某两点之间哪些公司通过自己拥有的路径单独联通。分析:问题开起来是给定了多个图,对他们分别求一个连通性,但是这里把多个图压缩到一个int型数字内,因为这里只是简简单单求一个连通性,使用位运算非常高效。代码如下:#include <iostream>#include <cstdlib>#include <cstdio>#include <cstring>using namespace std;int G[205][205];int N;void floyd() { for (int k = 1; 阅读全文
posted @ 2013-03-09 20:48 沐阳 阅读(227) 评论(0) 推荐(0) 编辑
摘要: 题意:从若干个S点出发到达T点,稍有不同的是,要区分该点落脚有左脚和右脚两种情况。解法:从题目中给定的S出发,左脚和右脚都可以踏上去,全部入队列后再spfa即可。做了这题发现使用spfa来处理多源点时连超级源点都不用建立了。代码如下:#include <iostream>#include <cstring>#include <cstdlib>#include <cstdio>#include <queue>using namespace std;const int INF = 0x3f3f3f3f;int N, M, dis[2][6 阅读全文
posted @ 2013-03-09 13:34 沐阳 阅读(301) 评论(0) 推荐(0) 编辑