#include <bits/stdc++.h>
using namespace std;
int n,m;
vector<int> v[100005];
int dp[100005];
void dfs(int p, int par)
{
dp[p] = 1;
bool can1=true, can=true;
for(int it : v[p])
{
if(it == par)
continue;
if((int)v[it].size() == 1)
continue;
dfs(it, p);
if(dp[it] == -1)
{
dp[p] = -1;
return;
}
dp[p] = 2;
if(dp[it] == 1 && can1)
can1 = false;
else
{
if(can)
can = false;
else
{
dp[p] = -1;
return;
}
}
}
}
int main()
{
cin>>n>>m;
if(m > n-1)
{
cout<<"NO";
return 0;
}
for(int i=1;i<n;i++)
{
int x, y;
cin>>x>>y;
v[x].push_back(y);
v[y].push_back(x);
}
for(int i=1;i<=n;i++)
{
dfs(i, 0);
if(dp[i] != -1)
{
cout<<"YES\n";
cout<<"1 1";
return 0;
}
}
cout<<"NO";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Partially correct |
1 ms |
2644 KB |
Failed to provide a successful strategy. |
3 |
Partially correct |
1 ms |
2644 KB |
Failed to provide a successful strategy. |
4 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
5 |
Partially correct |
2 ms |
2656 KB |
Failed to provide a successful strategy. |
6 |
Partially correct |
1 ms |
2644 KB |
Failed to provide a successful strategy. |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
9 |
Correct |
1 ms |
2644 KB |
Output is correct |
10 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
11 |
Partially correct |
1 ms |
2644 KB |
Failed to provide a successful strategy. |
12 |
Partially correct |
1 ms |
2644 KB |
Failed to provide a successful strategy. |
13 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
14 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
15 |
Partially correct |
3 ms |
2656 KB |
Failed to provide a successful strategy. |
16 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
17 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
18 |
Partially correct |
2 ms |
2772 KB |
Failed to provide a successful strategy. |
19 |
Partially correct |
2 ms |
2652 KB |
Failed to provide a successful strategy. |
20 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
21 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
22 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
23 |
Partially correct |
2 ms |
2592 KB |
Failed to provide a successful strategy. |
24 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
25 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
26 |
Partially correct |
1 ms |
2644 KB |
Failed to provide a successful strategy. |
27 |
Incorrect |
2 ms |
2644 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Partially correct |
1 ms |
2644 KB |
Failed to provide a successful strategy. |
3 |
Partially correct |
2 ms |
2580 KB |
Failed to provide a successful strategy. |
4 |
Partially correct |
2 ms |
2592 KB |
Failed to provide a successful strategy. |
5 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
6 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
7 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
8 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
9 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
10 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
11 |
Partially correct |
2 ms |
2636 KB |
Failed to provide a successful strategy. |
12 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
13 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
14 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
15 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
16 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
17 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
18 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
19 |
Partially correct |
3 ms |
2772 KB |
Failed to provide a successful strategy. |
20 |
Partially correct |
3 ms |
2644 KB |
Failed to provide a successful strategy. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Partially correct |
1 ms |
2644 KB |
Failed to provide a successful strategy. |
3 |
Partially correct |
1 ms |
2644 KB |
Failed to provide a successful strategy. |
4 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
5 |
Partially correct |
2 ms |
2656 KB |
Failed to provide a successful strategy. |
6 |
Partially correct |
1 ms |
2644 KB |
Failed to provide a successful strategy. |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
9 |
Correct |
1 ms |
2644 KB |
Output is correct |
10 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
11 |
Partially correct |
1 ms |
2644 KB |
Failed to provide a successful strategy. |
12 |
Partially correct |
1 ms |
2644 KB |
Failed to provide a successful strategy. |
13 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
14 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
15 |
Partially correct |
3 ms |
2656 KB |
Failed to provide a successful strategy. |
16 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
17 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
18 |
Partially correct |
2 ms |
2772 KB |
Failed to provide a successful strategy. |
19 |
Partially correct |
2 ms |
2652 KB |
Failed to provide a successful strategy. |
20 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
21 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
22 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
23 |
Partially correct |
2 ms |
2592 KB |
Failed to provide a successful strategy. |
24 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
25 |
Partially correct |
2 ms |
2644 KB |
Failed to provide a successful strategy. |
26 |
Partially correct |
1 ms |
2644 KB |
Failed to provide a successful strategy. |
27 |
Incorrect |
2 ms |
2644 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |