题意:A和B两人每人都熟悉一些单词。A先开始,每人说一个单词,单词不能与两人之前说过的所有单词重复,谁无话可说谁输。两人可能有共同会的单词。
分析:因为要让对方尽量无单词可说,所以每个人优先说的都是两人共同会的单词,假设两人共同会的单词数为common。
A会的单词数为n,B会的单词数为m。
1、common若为偶数,则两人说完共同会的单词后,若n-common>m-common,则A赢。
2、common若为奇数,则两人说完共同会的单词后,若n-common>m-common-1,则A赢。
#pragma comment(linker, "/STACK:102400000, 102400000") #include<cstdio> #include<cstring> #include<cstdlib> #include<cctype> #include<cmath> #include<iostream> #include<sstream> #include<iterator> #include<algorithm> #include<string> #include<vector> #include<set> #include<map> #include<stack> #include<deque> #include<queue> #include<list> #define Min(a, b) ((a < b) ? a : b) #define Max(a, b) ((a < b) ? b : a) typedef long long ll; typedef unsigned long long llu; const int INT_INF = 0x3f3f3f3f; const int INT_M_INF = 0x7f7f7f7f; const ll LL_INF = 0x3f3f3f3f3f3f3f3f; const ll LL_M_INF = 0x7f7f7f7f7f7f7f7f; const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1}; const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1}; const int MOD = 1e9 + 7; const double pi = acos(-1.0); const double eps = 1e-8; const int MAXN = 1000 + 10; const int MAXT = 500 + 10; using namespace std; string a[MAXN]; string b[MAXN]; int main(){ int n, m; while(scanf("%d%d", &n, &m) == 2){ for(int i = 0; i < n; ++i){ cin >> a[i]; } for(int i = 0; i < m; ++i){ cin >> b[i]; } int common = 0; for(int i = 0; i < n; ++i){ for(int j = 0; j < m; ++j){ if(a[i] == b[j]) ++common; } } if(common & 1){ if(n > m - 1){ printf("YES\n"); } else printf("NO\n"); } else{ if(n > m){ printf("YES\n"); } else printf("NO\n"); } } return 0; }