undirected专题

【HDU】5333 Undirected Graph【LCT+BIT】

传送门:【HDU】5333 Undirected Graph my  code: my~~code: #pragma comment(linker, "/STACK:1024000000")#include <stdio.h>#include <string.h>#include <map>#include <algorithm>using namespace std ;typed

323. Number of Connected Components in an Undirected Graph

寻找多少个独立的图,那不就是遍历完一个图,然后遍历其他图吗? 直到所有的点都遍历完。   创建两个unordered_set, 一个记录访问过的,一个记录没有访问过的点。   遍历每个图的节点的时候,动态的更新这两个set。 当第一个独立的图遍历完后 ret++; 如果记录没有访问过的点不为空,那么就继续循环去遍历。 这个办法可以,但是效率低。 class Solution { pub

Sicily Connect components in undirected graph

Source: http://soj.sysu.edu.cn/show_problem.php?pid=1002&cid=2104 Description 输入一个简单无向图,求出图中连通块的数目。 Sample Input 输入的第一行包含两个整数n和m,n是图的顶点数,m是边数。1<=n<=1000,0<=m<=10000。 以下m行,每行是一个数对v y,表示存在边(v,y)。顶