CodeForces - 755B PolandBall and Game(博弈)
题意: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(博弈)的更多相关文章
- Codeforces 755B. PolandBall and Game 贪心
题目大意: 有两个人轮流说单词,已经说过的单词不能再说.给出两人掌握的不同的单词,两人可能掌握相同的单词,但是这个单词也只能说一边.问在两人都是最优策略下先手是否必胜. 题解: 我们发现最优策略一定是 ...
- 【codeforces 755B】PolandBall and Game
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- Codeforces 755B:PolandBall and Game(map+思维)
http://codeforces.com/problemset/problem/755/B 题意:A可以喊出n个字符串,B可以喊出m个字符串,如果一个字符串之前被喊过,那么它再也不能喊了,A先喊,最 ...
- codeforces 755C. PolandBall and Forest
C. PolandBall and Forest time limit per test 1 second memory limit per test 256 megabytes input stan ...
- codeforces 755D. PolandBall and Polygon
D. PolandBall and Polygon time limit per test 4 seconds memory limit per test 256 megabytes input st ...
- Codeforces 755F PolandBall and Gifts bitset + 二进制优化多重背包
PolandBall and Gifts 转换成置换群后, 对于最大值我们很好处理. 对于最小值, 只跟若干个圈能否刚好组能 k 有关. 最直观的想法就是bitset优化背包, 直接搞肯定T掉. 我们 ...
- codeforces 755D. PolandBall and Polygon(线段树+思维)
题目链接:http://codeforces.com/contest/755/problem/D 题意:一个n边形,从1号点开始,每次走到x+k的位置如果x+k>n则到x+k-n的位置,问每次留 ...
- Codeforces 1162E Thanos Nim(博弈)
一道有意思的博弈题.首先我们考虑一种必败情况,那就是有一方拿光了一堆石子,显然对方是必胜,此时对方可以全部拿走其中的n/2,那么轮到自己时就没有n/2堆,所以此时是必败态.我们先对所有石子堆sort, ...
- CodeForces 755C PolandBall and Forest (并查集)
题意:给定每一点离他最远的点,问是这个森林里有多少棵树. 析:并查集,最后统计不同根结点的数目即可. 代码如下: #pragma comment(linker, "/STACK:102400 ...
随机推荐
- Python正则表达式就是这么简单【新手必学】
一前言本篇文章带大家快速入门正则表达式的使用,正则表达式的规则不仅适用python语言,基本大多数编程语言都适用,在日常使用中极为广泛,读者们有必要学好正则表达式.看完这篇文章,读者们要理解什么是正则 ...
- SpringBoot 集成Spring JDBC
(1)在pom.xml中添加依赖 <!--spring-jdbc的依赖--> <dependency> <groupId>org.springframework.b ...
- 107、Java中String类之判断开头或结尾
01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public ...
- 编写跨平台Java程序注意事项
使用Java语言编写应用程序最大的优点在于“一次编译,处处运行”,然而这并不是说所有的Java程序都具有跨平台的特性,事实上,相当一部分的Java程序是不能在别的操作系统上正确运行的,那么如何才能编写 ...
- pytorch中tensor张量数据基础入门
pytorch张量数据类型入门1.对于pytorch的深度学习框架,其基本的数据类型属于张量数据类型,即Tensor数据类型,对于python里面的int,float,int array,flaot ...
- java set的线程安全
CopyOnWriteArraySet和ConcurrentSkipListSet 与线程不安全的集合类的对应关系 HashSet -> CopyOnWriteArraySet TreeSet ...
- 简单讲解什么是黑帽SEO
此文章主要讲的是黑帽SEO之搜索引擎劫持: SEO(Search Engine Optimization)搜索引擎优化,简单来说,就是让网站的排名更高,比如,搜索"博客"这个关键字 ...
- java的浅拷贝和深拷贝(待解决)
1.什么是浅拷贝,什么是深拷贝? 2.storm的并行度问题,需要使用全局变量static ConcorrentHashMap,因为加了static,所有的线程只能拷贝该全局变量的一个唯一的副本,进行 ...
- sentinel控制台
下载sentinel源码包:https://github.com/alibaba/Sentinel/tree/master,根据自己需要下载不同版本的分支,博主下载得是1.6 下载后解压,然后进入se ...
- Glove - sh demo.sh出错 Error: suffix or operands invalid for `vbroadcastss'
Glove+Python,使用预训练模型,执行sh demo.sh 报错:Error: suffix or operands invalid for `vbroadcastss' 解决:修改Makef ...