题意: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[] = {, , -, , -, -, , };
const int dc[] = {-, , , , -, , -, };
const int MOD = 1e9 + ;
const double pi = acos(-1.0);
const double eps = 1e-;
const int MAXN = + ;
const int MAXT = + ;
using namespace std;
string a[MAXN];
string b[MAXN];
int main(){
int n, m;
while(scanf("%d%d", &n, &m) == ){
for(int i = ; i < n; ++i){
cin >> a[i];
}
for(int i = ; i < m; ++i){
cin >> b[i];
}
int common = ;
for(int i = ; i < n; ++i){
for(int j = ; j < m; ++j){
if(a[i] == b[j]) ++common;
}
}
if(common & ){
if(n > m - ){
printf("YES\n");
}
else printf("NO\n");
}
else{
if(n > m){
printf("YES\n");
}
else printf("NO\n");
}
}
return ;
}

CodeForces - 755B PolandBall and Game(博弈)的更多相关文章

  1. Codeforces 755B. PolandBall and Game 贪心

    题目大意: 有两个人轮流说单词,已经说过的单词不能再说.给出两人掌握的不同的单词,两人可能掌握相同的单词,但是这个单词也只能说一边.问在两人都是最优策略下先手是否必胜. 题解: 我们发现最优策略一定是 ...

  2. 【codeforces 755B】PolandBall and Game

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  3. Codeforces 755B:PolandBall and Game(map+思维)

    http://codeforces.com/problemset/problem/755/B 题意:A可以喊出n个字符串,B可以喊出m个字符串,如果一个字符串之前被喊过,那么它再也不能喊了,A先喊,最 ...

  4. codeforces 755C. PolandBall and Forest

    C. PolandBall and Forest time limit per test 1 second memory limit per test 256 megabytes input stan ...

  5. codeforces 755D. PolandBall and Polygon

    D. PolandBall and Polygon time limit per test 4 seconds memory limit per test 256 megabytes input st ...

  6. Codeforces 755F PolandBall and Gifts bitset + 二进制优化多重背包

    PolandBall and Gifts 转换成置换群后, 对于最大值我们很好处理. 对于最小值, 只跟若干个圈能否刚好组能 k 有关. 最直观的想法就是bitset优化背包, 直接搞肯定T掉. 我们 ...

  7. codeforces 755D. PolandBall and Polygon(线段树+思维)

    题目链接:http://codeforces.com/contest/755/problem/D 题意:一个n边形,从1号点开始,每次走到x+k的位置如果x+k>n则到x+k-n的位置,问每次留 ...

  8. Codeforces 1162E Thanos Nim(博弈)

    一道有意思的博弈题.首先我们考虑一种必败情况,那就是有一方拿光了一堆石子,显然对方是必胜,此时对方可以全部拿走其中的n/2,那么轮到自己时就没有n/2堆,所以此时是必败态.我们先对所有石子堆sort, ...

  9. CodeForces 755C PolandBall and Forest (并查集)

    题意:给定每一点离他最远的点,问是这个森林里有多少棵树. 析:并查集,最后统计不同根结点的数目即可. 代码如下: #pragma comment(linker, "/STACK:102400 ...

随机推荐

  1. 本地启动tomcat的时候报java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: PermGen space

    1.问题:我在tomcat中放入了大量的war包,启动的时候报:java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: ...

  2. Guava LoadingCache不能缓存null值

    测试的时候发现项目中的LoadingCache没有刷新,但是明明调用了refresh方法了.后来发现LoadingCache是不支持缓存null值的,如果load回调方法返回null,则在get的时候 ...

  3. js通过cookie对两个没有关系的jsp页面进行传值

    //Cookie取值 function readCookie (name) { var cookieValue = ""; var search = name + "=& ...

  4. JSP数据交互二

    1.JSP内置对象:JSP内置对象是 Web 容器创建的一组对象,不用通过手动new就可以使用2.JSP9大内置对象:      对象名称 类型 request (请求对象)  javax.servl ...

  5. 第1节 kafka消息队列:11、kafka的数据不丢失机制,以及kafka-manager监控工具的使用;12、课程总结

    12.kafka如何保证数据的不丢失 12.1生产者如何保证数据的不丢失 kafka的ack机制:在kafka发送数据的时候,每次发送消息都会有一个确认反馈机制,确保消息正常的能够被收到 如果是同步模 ...

  6. 一、java基础-数据类型_数据类型转化_字符编码_转义字符

    1.Java  支持的8种基本数据类型: java的四种整数数据类型:byte 1    short 2     int4     long8   byte     8位带符号整数 -128到127之 ...

  7. 解决css中display:inline-block的兼容问题

    *display:inline; *zoom:1; 不多说,ie6/7直接在元素添加以上的属性即可.

  8. JS弹出层制作,以及移动端禁止弹出层下内容滚动,overflow:hidden移动端失效问题

    HTML <div class="layer"> <div class="menu-list"> <span>社会</ ...

  9. 一个前端博主的nginx+php+mysql的环境搭建

    这几天天某的公司给了在下一个需求,让我修改一个后端大佬用PHP写的一个官网,虽然说修改的内容还是很简单,但是毕竟之前还是没接触过PHP,于是开始了漫长的爬坑之旅,话不多说,这次就给大家介绍一下我配置安 ...

  10. 「NOIP2007」树网的核

    传送门 Luogu 解题思路 这里着重介绍 \(O(n^3)\) 的做法,毕竟考场上只有 \(N\le300\) \(Q \omega Q\) 首先我们要知道,对任意一条直径算偏心距都是一样的. 证明 ...