#include <bits/stdc++.h>
using namespace std;
int n, m;
vector< vector<int> > grp;
vector<int> used;
void dfs ( int v, int p )
{
used[v] = 1;
for ( auto& to : grp[v] )
if ( to != p )
{
if ( used[to] )
{
cout << "NO\n";
exit(0);
}
dfs( to, v );
}
}
int main ()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
grp.resize( n+1 );
for ( int i=0; i<m; i++ )
{
int u, v;
cin >> u >> v;
grp[u].push_back( v );
grp[v].push_back( u );
}
used.assign( n+1, 0 );
dfs( 1, -1 );
cout << "YES 0";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Integer parameter [name=k] equals to 0, violates the range [1, 5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
320 KB |
Integer parameter [name=k] equals to 0, violates the range [1, 5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Integer parameter [name=k] equals to 0, violates the range [1, 5] |
2 |
Halted |
0 ms |
0 KB |
- |