Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
68284 | 桑迪 | 通信系统 | C++ | 通过 | 100 | 144 MS | 260 KB | 411 | 2023-02-03 17:53:32 |
#include<bits/stdc++.h> using namespace std; int n,m,p[1010],a,b,f,cnt; int find(int x){ if(p[x]-x) p[x]=find(p[x]); return p[x]; } int main(){ while(cin>>n>>m,n+m){ f=1,cnt=0; for(int i=1;i<=n;i++) p[i]=i; while(m--){ cin>>a>>b; if(find(a)-find(b))p[find(b)]=find(a); else f=0; }for(int i=1;i<=n;i++)cnt+=(p[i]==i); cout<<(f&&!(--cnt)?"Yes":"No")<<"\n"; } return 0; }