题目链接:http://codeforces.com/contest/755/problem/B

题意:给定PolandBall 和EnemyBall 这2个人要说的单词,然后每一回合轮到的人要说一个单词,之前说过的单词不能再说,当轮到某个人的回合没单词说即输。每人都采取最优策略,PolandBall 先说问PolandBall 是否能赢。

思路: 首先两个的单词可以分为相同和不相同两个部分,由于说过的词不能重复说所以比起说不相同的那部分的单词还是说相同的那部分比较优,因为说了一个对面有的但是目前还没说的单词那么对方就会少一个单词。然后模拟即可。

import java.io.PrintWriter;
import java.util.*; public class Main {
public static final int MAXN=100000+10;
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int n=cin.nextInt(),m=cin.nextInt();
HashSet<String>se=new HashSet<String>();
for(int i=1;i<=n;i++){
String str=cin.next();
se.add(str);
}
int Same=0; boolean flag=true,OK=false;
for(int i=1;i<=m;i++){
String str=cin.next();
if(se.contains(str)==true){
Same++;
}
}
int OtherP=n-Same, OtherE=m-Same;
for(int i=0; OK==false ;i++){
if(i%2==0){
if(Same==0&&OtherP==0){
flag=false; OK=true;
}
if(Same>0){
Same--;
}else{
OtherP--;
}
}
else{
if(Same==0&&OtherE==0){
flag=true; OK=true;
}
if(Same>0){
Same--;
}else{
OtherE--;
}
}
}
out.printf(flag==true?"YES\n":"NO\n");
cin.close();
out.flush();
}
}

8VC Venture Cup 2017 - Elimination Round - B的更多相关文章

  1. 8VC Venture Cup 2017 - Elimination Round

    传送门:http://codeforces.com/contest/755 A题题意是给你一个数字n,让你找到一个数字m,使得n*m+1为合数,范围比较小,直接线性筛出1e6的质数,然后暴力枚举一下就 ...

  2. 解题报告8VC Venture Cup 2017 - Elimination Round

    题目链接:http://codeforces.com/contest/755 本蒟蒻做了半天只会做前两道题.. A. PolandBall and Hypothesis 题意:给出n,让你找出一个m, ...

  3. 8VC Venture Cup 2017 - Elimination Round - C

    题目链接:http://codeforces.com/contest/755/problem/C 题意:PolandBall 生活在一个森林模型的环境中,定义森林由若干树组成,定义树为K个点,K-1条 ...

  4. 8VC Venture Cup 2017 - Elimination Round - A

    题目链接:http://codeforces.com/contest/755/problem/A 题意:给定一个正整数N,问你是否存在一个数M使得N*M+1不是素数(M的范围在[1,1000]). 思 ...

  5. Codeforces Round #393 (Div. 2) (8VC Venture Cup 2017 - Final Round Div. 2 Edition)A 水 B 二分 C并查集

    A. Petr and a calendar time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  6. 8VC Venture Cup 2016 - Elimination Round D. Jerry's Protest 暴力

    D. Jerry's Protest 题目连接: http://www.codeforces.com/contest/626/problem/D Description Andrew and Jerr ...

  7. 8VC Venture Cup 2016 - Elimination Round

    在家补补题   模拟 A - Robot Sequence #include <bits/stdc++.h> char str[202]; void move(int &x, in ...

  8. 8VC Venture Cup 2016 - Elimination Round (C. Block Towers)

    题目链接:http://codeforces.com/contest/626/problem/C 题意就是给你n个分别拿着2的倍数积木的小朋友和m个分别拿着3的倍数积木的小朋友,每个小朋友拿着积木的数 ...

  9. codeforces 8VC Venture Cup 2016 - Elimination Round C. Lieges of Legendre

    C. Lieges of Legendre 题意:给n,m表示有n个为2的倍数,m个为3的倍数:问这n+m个数不重复时的最大值 最小为多少? 数据:(0 ≤ n, m ≤ 1 000 000, n + ...

随机推荐

  1. $nextTick

    Vue 实现响应式并不是数据发生变化之后 DOM 立即变化,而是按一定的策略进行 DOM 的更新. $nextTick 是在下次 DOM 更新循环结束之后执行延迟回调,在修改数据之后使用 $nextT ...

  2. vue组件传值之父传子

    1.父组件给子组件传值  home父组件  header子组件  关键字props home代码 <template> <div> <v-header :title=&q ...

  3. 生产环境下,oracle不同用户间的数据迁移。第一部分

    :任务名称:生产环境下schema ELON数据迁移至schema TIAN ######################################## 测试一:测试参数 数据泵数据导出:exp ...

  4. php基础/类型

    1.php的格式: <?php ?> 内嵌格式: <? ?> (php可以写在html文件里面) 2.php的输出:echo (每段的结束必须加;) 3.定义变量: 不需要管他 ...

  5. Linux运维知识之linux shell date 用当天时间做备份文件名

    本文主要向大家介绍了Linux运维知识之linux shell date 用当天时间做备份文件名,通过具体的内容向大家展现,希望对大家学习Linux运维知识有所帮助. #!/bin/bash #dat ...

  6. python读写excle

    我们可以通过python的一些模块进行excle中用例的读取,或者导出数据到excle 目录 1.安装模块 2.读excle 3.写excle 1.安装模块 python中有第三方模块可以进行excl ...

  7. Jmeter接口测试报告模板优化

    优化后在接口报告的接口信息中,直接展示url,method,结果和响应时间,详情中展示请求和响应数据.具体如下: 模板文件 jmeter-results-detail-report_21.xsl: & ...

  8. 【转载】Spring Boot:常用属性汇总

    附录A.常用应用程序属性 摘自:https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-pr ...

  9. virtualenv-windows下排坑

    1. 安装 pip install virtualenv pip install virtualenvwrapper-win    (win下一定要有这个 -win,不然后续 workon,mkvir ...

  10. poj1258Agri-Net(最小生成树)

    题目链接:http://poj.org/problem?id=1258 Description Farmer John has been elected mayor of his town! One ...