Codeforces 755b:polandball and Game (map+ thinking)

Source: Internet
Author: User

Http://codeforces.com/problemset/problem/755/B

Test instructions: A can shout out n string, B can shout out M string, if a string was shouted before, then it could no longer shout, a first shout, finally did not shout lose. Ask who wins.

Idea: Use map to judge A, b in the same number of strings, because a can shout first, then B shout, everyone can shout the number to subtract CNT/2 (if it is odd, a can shout more one), said the other shouted. If the last N<=m is a lose, otherwise a win, equal to the situation is because a first shout, B again shout, to the last a will lose.

1#include <cstdio>2#include <cstring>3#include <cmath>4#include <cstdlib>5#include <algorithm>6#include <string>7#include <iostream>8#include <stack>9#include <map>Ten#include <queue> One#include <Set> A using namespacestd; -typedefLong LongLL; - #defineN 100010 the #defineINF 0x3f3f3f3f - strings1[1010]; - strings2[1010]; -map<string,int>MP; +  - intMain () + { A     intn,m; atCIN >> N >>m; -      for(inti =1; I <= N; i++) Cin >>S1[i]; -      for(inti =1; I <= m; i++) Cin >>S2[i]; -     intf =0; -      for(inti =1; I <= N; i++) Mp[s1[i] =1; -      for(inti =1; I <= m; i++)if(Mp[s2[i]]) f++; inN-= (f/2); M-= (F-f/2); -     if(n > M) puts ("YES"); to     ElsePuts"NO"); +     return 0; -}

Codeforces 755b:polandball and Game (map+ thinking)

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.