摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4751思路:构建新图,对于那些两点连双向边的,忽略,然后其余的都连双向边,于是在新图中,连边的点是能不在同一个图中的,于是我们可以用dfs染色的方法来判断是否存矛盾。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 int map[111][111]; 9 int color[111];10 int n;11 vector >g;12 13 bool dfs(int u,int 阅读全文
posted @ 2013-09-22 15:36 ihge2k 阅读(467) 评论(0) 推荐(1) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2545思路:dist[u]表示节点u到根节点的距离,然后在查找的时候更新即可,最后判断dist[u],dist[v]的大小即可。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define MAXN 101000 8 9 int n,m;10 int parent[MAXN];11 int dist[MAXN];12 13 int Find(int x)14 {15 if(x... 阅读全文
posted @ 2013-09-22 11:06 ihge2k 阅读(414) 评论(0) 推荐(0) 编辑