#include <bits/stdc++.h>
#define pb push_back
#define spc << " " <<
#define endl "\n"
#define all(x) x.begin(), x.end()
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define mid (l+r)/2
#define inf 1e15
#define MOD 998244353
#define MX 1005
using namespace std;
vi edges[MX];
int rdep[MX];
int dfs(int node, int pa){
rdep[node]=0;
int cnt=0;
for(auto i:edges[node]){
if(i==pa) continue;
if(!dfs(i, node)) return 0;
rdep[node]=max(rdep[node], rdep[i]+1);
if(rdep[i]>1) cnt++;
if(cnt>2) return 0;
}
return 1;
}
void solve(){
int n,m; cin >> n >> m;
for(int i=1; i<=m; i++){
int a,b; cin >> a >> b;
edges[a].pb(b);
edges[b].pb(a);
}
if(m>=n){
cout << "NO\n";
return;
}
for(int r=1; r<=n; r++){
if(!dfs(r, 0)){
cout << "NO\n";
return;
}
}
cout << "YES\n";
}
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);
#ifdef Local
freopen("in","r",stdin);
freopen("out","w",stdout);
/*#else
freopen("248.in","r",stdin);
freopen("248.out","w",stdout);*/
#endif
int t=1;
//cin >> t;
while(t--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |