Title effect: There are no $ a $ n $ m $ points of edges connected graph, which determines whether $ 3 $ separated rings, three rings meet and cover the entire FIG no duplicate edges. $ n, m \ leqslant10 ^ 5
Solution: Classification discussion. There are given in degrees Qiken not, because the communication, if it is greater than the number of ring $ 3 $ must be combined, so only need to exclude the number of ring less than $ 3 $ case.
When all the points degrees less than $ 4 $ Certainly not, when the maximum degree greater than $ 4 $ will be able to. Then we discuss the maximum point of degree $ 4 $ in the case. When only one point of degree $ 4 $, corresponds to from two rings, not. When there is a degree greater than two points can be when the $ 4 $. When there are two points of degree $ 4 $, except for the following case can rest.
The judge in this case only surprise in $ A $ if you can not point $ B $ back by itself, it is possible, otherwise it is the case above.
Card point: None
C++ Code:
#include <cstdio> #include <cstdlib> #include <iostream> #include <algorithm> const int maxn = 1e5 + 10; int n, m, deg[maxn], Max, Cnt, A, B; int head[maxn], cnt; struct Edge { int to, nxt; } e[maxn << 1]; void addedge(int a, int b) { e[++cnt] = (Edge) { b, head[a] }; head[a] = cnt; e[++cnt] = (Edge) { a, head[b] }; head[b] = cnt; ++deg[a], ++deg[b]; } void dfs(int u, int fa = 0) { if (u == A && fa) std::cout << "Yes\n", exit(0); if (u == B) return ; for (int i = head[u], v; i; i = e[i].nxt) if ((v = e[i].to) != fa) dfs(v, u); } int main() { std::ios::sync_with_stdio(false), std::cin.tie(0), std::cout.tie(0); std::cin >> n >> m; for (int i = 0, a, b; i < m; ++i) std::cin >> a >> b, addedge(a, b); for (int i = 1; i <= n; ++i) if (deg[i] & 1) { std::cout << "No\n"; return 0; } else { Max = std::max(Max, deg[i]); if (deg[i] == 4) { ++Cnt; if (A) B = i; else A = i; } } if (Max < 4 || (Max == 4 && Cnt == 1)) { std::cout << "No\n"; return 0; } if (Max > 4 || Cnt > 2) { std::cout << "Yes\n"; return 0; } dfs(A), std::cout << "No\n"; return 0; }