#include "bits/stdc++.h"
using namespace std;
#ifdef Nero
#include "Deb.h"
#else
#define deb(...)
#endif
const int N = 2e5 + 5;
int a, b;
int dep[N];
vector<int> g[N];
void dfs(int v, int p, int& x) {
if (dep[v] >= dep[x]) {
x = v;
}
for (int u : g[v]) {
if (u == p) continue;
dep[u] = dep[v] + 1;
dfs(u, v, x);
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
int mxdegree = 0;
for(int i = 0; i < m; ++i) {
int u, v;
cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
mxdegree = max(mxdegree, (int) g[v].size());
mxdegree = max(mxdegree, (int) g[u].size());
}
dfs(1, 1, a);
dfs(a, a, b);
if (mxdegree >= 3 && dep[b] > 4) {
cout << "NO" << '\n';
return 0;
}
cout << "YES" << '\n';
cout << 1 << '\n';
cout << 1 << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
Output is correct |
2 |
Partially correct |
1 ms |
4956 KB |
Failed to provide a successful strategy. |
3 |
Partially correct |
1 ms |
4956 KB |
Failed to provide a successful strategy. |
4 |
Partially correct |
1 ms |
4956 KB |
Failed to provide a successful strategy. |
5 |
Partially correct |
1 ms |
4956 KB |
Failed to provide a successful strategy. |
6 |
Incorrect |
1 ms |
4956 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
5208 KB |
Output is correct |
2 |
Partially correct |
1 ms |
4956 KB |
Failed to provide a successful strategy. |
3 |
Partially correct |
1 ms |
4956 KB |
Failed to provide a successful strategy. |
4 |
Partially correct |
1 ms |
4956 KB |
Failed to provide a successful strategy. |
5 |
Partially correct |
1 ms |
4956 KB |
Failed to provide a successful strategy. |
6 |
Partially correct |
1 ms |
4956 KB |
Failed to provide a successful strategy. |
7 |
Partially correct |
1 ms |
4956 KB |
Failed to provide a successful strategy. |
8 |
Partially correct |
1 ms |
4956 KB |
Failed to provide a successful strategy. |
9 |
Partially correct |
1 ms |
4956 KB |
Failed to provide a successful strategy. |
10 |
Partially correct |
1 ms |
4956 KB |
Failed to provide a successful strategy. |
11 |
Partially correct |
2 ms |
5212 KB |
Failed to provide a successful strategy. |
12 |
Partially correct |
2 ms |
5208 KB |
Failed to provide a successful strategy. |
13 |
Partially correct |
1 ms |
5212 KB |
Failed to provide a successful strategy. |
14 |
Partially correct |
1 ms |
5212 KB |
Failed to provide a successful strategy. |
15 |
Partially correct |
2 ms |
5212 KB |
Failed to provide a successful strategy. |
16 |
Partially correct |
2 ms |
5212 KB |
Failed to provide a successful strategy. |
17 |
Partially correct |
1 ms |
5212 KB |
Failed to provide a successful strategy. |
18 |
Partially correct |
1 ms |
5208 KB |
Failed to provide a successful strategy. |
19 |
Partially correct |
1 ms |
5212 KB |
Failed to provide a successful strategy. |
20 |
Partially correct |
1 ms |
5208 KB |
Failed to provide a successful strategy. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
Output is correct |
2 |
Partially correct |
1 ms |
4956 KB |
Failed to provide a successful strategy. |
3 |
Partially correct |
1 ms |
4956 KB |
Failed to provide a successful strategy. |
4 |
Partially correct |
1 ms |
4956 KB |
Failed to provide a successful strategy. |
5 |
Partially correct |
1 ms |
4956 KB |
Failed to provide a successful strategy. |
6 |
Incorrect |
1 ms |
4956 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |