CODEFORCES-755B Polandball and Game (game)

Source: Internet
Author: User



Test instructions: Both A and b are familiar with some words. A first, each said a word, the word can not be the two people said before all the words repeat, who have nothing to say who lose. Two people may have a common word.



Analysis: Because to let the other side as far as possible without words can be said, so everyone priority is the words of two people together, assuming that the two people together will be the number of words common.



A will have a number of words n,b will be the number of words M.



1, if the common is even, then two people said after the common words, if n-common>m-common, then a win.



2, common if is odd, then two people said after the common words, if n-common>m-common-1, then a win.


#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;
}





CODEFORCES-755B Polandball and Game (game)


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.