题意: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. Linux命令:top命令

    top命令是Linux下常用的性能分析工具,能够实时显示系统中各个进程的资源占用状况,类似于Windows的任务管理器.下面详细介绍它的使用方法.top是一个动态显示过程,即可以通过用户按键来不断刷新 ...

  2. C++中函数访问数组的方式

    在书写C++代码时,往往为了令代码更加简洁高效.提高代码可读性,会对定义的函数有一些特殊的要求:比如不传递不必要的参数,以此来让函数的参数列表尽可能简短. 当一个函数需要访问一个数组元素时,出于上述原 ...

  3. 树 插件 ztree 的基本用法

    因业务需要 用到 ztree 插件 第一次用tree插件上手有点难度 官网 http://www.treejs.cn/v3/main.php#_zTreeInfo 第一步:初始化树,树的所有数据从后台 ...

  4. SSM项目中,关于Test类中不能使用Autowired注入bean的问题

    在测试类中使用AutoWired注解一直不能获取到Bean,调用方法时一直报空指针异常,我有在其他类中使用AutoWired试了下,发现能够生效.问题应该就是处在Test类中,后面找了半天终于找到问题 ...

  5. redhat 7.6 常用命令

    cp 复制命令 diff  对比两个文件内容是否相同 cp -rvf  复制目录 r代表递归 v显示详细步骤 f强制 ls -ah   查看目录  a查看隐藏文件 h显示文件大小单位k less 逐行 ...

  6. window查看连接过的无线密码

    for /f "skip=9 tokens=1,2 delims=:" %i in ('netsh wlan show profiles') do  @echo %j | find ...

  7. MVC webuploader 图片

    AARTO:SaveNoticeAndDocument ~/Scripts/Upload/webuploader-0.1.4/dist/webuploader.js

  8. CentOS7 安装PHP7的swoole扩展:

    一.绪 Swoole简介 PHP异步网络通信引擎 最终编译为so文件作为PHP的扩展 准备工作 Linux环境 PHP7 swoole2.1 redis 源码安装PHP7 源码安装swoole htt ...

  9. java并发:原子类之AtomicLong

    原子类之AtomicLong java线程中的操作,需要满足原子性.可见性等原则,比如i++这样的操作不具备原子性, A线程读取了i,另一个线程执行i++,A线程再执行i++就会引发线程安全问题 推荐 ...

  10. bzoj 4747: [Usaco2016 Dec]Counting Haybales

    23333,在扒了一天题解之后发现我竟然还能秒题,虽然这是个pj的sb题... (排个序,然后upper_bound和lower_bound一用就行了(是不是有O(1)的查询方法啊??貌似要离散啊,一 ...