intmain() { cin >> n >> m; if (n != m) cout << "NO" << endl; else { for (int i = 1; i <= n; i ++ ) p[i] = i; int cnt = n; // 存储集合的数量 for (int line = 0; line < m; line ++ ) { int a, b; cin >> a >> b; if (find(a) != find(b)) { cnt -- ; p[find(a)] = find(b); } } if (cnt == 1) cout << "YES" << endl; else cout << "NO" << endl; } return0; }