#include "bits/stdc++.h"
using namespace std;
#ifdef Nero
#include "Deb.h"
#else
#define deb(...)
#endif
const int N = 1e3 + 3;
vector<int> g[N];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
for (int i = 0; i < m; ++i) {
int u, v;
cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}
vector<int> freq(2);
vector<int> color(n + 1, -1);
function<void(int, bool)> Dfs = [&](int v, bool c) {
color[v] = c;
freq[c]++;
for (int u : g[v]) {
if (color[u] == -1) {
Dfs(u, !c);
}
}
};
Dfs(1, 1);
if (n == 1) {
cout << "YES" << '\n';
cout << 1 << '\n' << 1 << '\n';
return 0;
}
for (int i = 1; i <= n; ++i) {
assert(color[i] != -1);
if (freq[color[i]] == 1) {
cout << "YES" << '\n';
cout << 2 << '\n';
cout << i << ' ' << i << '\n';
return 0;
}
}
cout << "NO" << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |