1 solutions
-
0
#include<bits/stdc++.h> using namespace std; const int N=110; string a[N],b[N]; int main() { int n; cin>>n; map<string,int> h; for(int i=1;i<=n;i++) { cin>>a[i]>>b[i]; h[a[i]]++,h[b[i]]++; } for(int i=1;i<=n;i++) { bool st=false;//还没有选择 if(h[a[i]]==1) st=1; //姓没有冲突 if(h[b[i]]==1) st=1; //名没有冲突 if(a[i]==b[i]&&h[a[i]]==2) //自己的姓和名一样,和别人没有冲突 { st=1; } if(st==0) { cout<<"No"; return 0; } } cout<<"Yes"; return 0; }
- 1
Information
- ID
- 2438
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 1
- Tags
- (None)
- # Submissions
- 6
- Accepted
- 2
- Uploaded By