#include <bits/stdc++.h>
#define ar array
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
const int N = 1005;
vector <int> g[N];
int vis[N], ok = 1;
void dfs(int x, int par) {
vis[x] = 1;
for (int y : g[x]) {
if (y != par) {
if (vis[y]) {
ok = 0;
} else {
dfs(y, x);
}
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n, m;
cin >> n >> m;
for (int i = 0; i < m; i++) {
int a, b;
cin >> a >> b;
g[a].emplace_back(b);
g[b].emplace_back(a);
}
dfs(1, 0);
if (ok) {
cout << "YES\n";
cout << "1\n1";
} else {
cout << "NO\n";
}
return 0;
}
/*
if cycle -> NO
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |