本文共 1322 字,大约阅读时间需要 4 分钟。
题意异常的简单。就是给定一个邻接矩阵,让你判定是否为树。
1 /* 472D */ 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 #include 13 #include 14 #include 15 #include 16 #include 17 #include 18 #include 19 using namespace std; 20 //#pragma comment(linker,"/STACK:102400000,1024000") 21 22 #define mpii map 23 #define vi vector 24 #define pii pair 25 #define vpii vector > 26 #define rep(i, a, n) for (int i=a;i =a;--i) 28 #define pb push_back 29 #define mp make_pair 30 #define fir first 31 #define sec second 32 #define all(x) (x).begin(),(x).end() 33 #define SZ(x) ((int)(x).size()) 34 #define lson l, mid, rt<<1 35 #define rson mid+1, r, rt<<1|1 36 37 const int maxn = 2005; 38 const int INF = 0x3f3f3f3f; 39 int M[maxn][maxn]; 40 int T[maxn][maxn]; 41 int dist[maxn]; 42 int fa[maxn]; 43 bool visit[maxn]; 44 int n; 45 46 void kruskal() { 47 memset(visit, false, sizeof(visit)); 48 memset(dist, 0x3f, sizeof(dist)); 49 int v, mn; 50 int i, j, k; 51 52 dist[0] = 0; 53 for (i=0; i
转载于:https://www.cnblogs.com/bombe1013/p/4596576.html