标签:des style io color ar os sp java for
3 Alice Bob Smith John Alice Smith 5 a c c d d e b e a d 0
Yes No
#include <map> #include <set> #include <list> #include <queue> #include <stack> #include <vector> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; const int N = 1010; int n; char str1[110], str2[110]; int in[N]; int main() { while (~scanf("%d", &n), n) { map<string, int>qu; memset (in, 0, sizeof(in)); qu.clear(); int cnt = 0; for (int i = 1; i <= n; ++i) { scanf("%s%s", str1, str2); if (qu[str1] == 0) { qu[str1] = ++cnt; } if (qu[str2] == 0) { qu[str2] = ++cnt; } in[qu[str2]]++; } int ans = 0; for (int i = 1; i <= cnt; ++i) { if (in[i] == 0) { ans++; } } if (ans >= 2 || ans == 0) { printf("No\n"); continue; } printf("Yes\n"); } return 0; }
标签:des style io color ar os sp java for
原文地址:http://blog.csdn.net/guard_mine/article/details/41214953