8VC Venture Cup 2017 - Elimination Round - B
题目链接: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的更多相关文章
- 8VC Venture Cup 2017 - Elimination Round
传送门:http://codeforces.com/contest/755 A题题意是给你一个数字n,让你找到一个数字m,使得n*m+1为合数,范围比较小,直接线性筛出1e6的质数,然后暴力枚举一下就 ...
- 解题报告8VC Venture Cup 2017 - Elimination Round
题目链接:http://codeforces.com/contest/755 本蒟蒻做了半天只会做前两道题.. A. PolandBall and Hypothesis 题意:给出n,让你找出一个m, ...
- 8VC Venture Cup 2017 - Elimination Round - C
题目链接:http://codeforces.com/contest/755/problem/C 题意:PolandBall 生活在一个森林模型的环境中,定义森林由若干树组成,定义树为K个点,K-1条 ...
- 8VC Venture Cup 2017 - Elimination Round - A
题目链接:http://codeforces.com/contest/755/problem/A 题意:给定一个正整数N,问你是否存在一个数M使得N*M+1不是素数(M的范围在[1,1000]). 思 ...
- 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 ...
- 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 ...
- 8VC Venture Cup 2016 - Elimination Round
在家补补题 模拟 A - Robot Sequence #include <bits/stdc++.h> char str[202]; void move(int &x, in ...
- 8VC Venture Cup 2016 - Elimination Round (C. Block Towers)
题目链接:http://codeforces.com/contest/626/problem/C 题意就是给你n个分别拿着2的倍数积木的小朋友和m个分别拿着3的倍数积木的小朋友,每个小朋友拿着积木的数 ...
- 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 + ...
随机推荐
- 如何修改Pspice元件库中元件的模型参数?
比如下面是我取出的一个稳压管参数....* created using Parts release 7.1p on 11/03/98 * per Microsemi estimate: Trr(est ...
- python 按多维列表中的某一个元素位进行排序
import os,re top = os.popen("tasklist") process_list = [] split_r = r"\s+" memor ...
- sys模块 json pickle模块
# sys模块# import sys# sys.path# sys.argv# sys.exit() # 脚本退出# print('[%s]'%('#'*1))# print('[%s]'%('#' ...
- 【leetcode】1047. Remove All Adjacent Duplicates In String
题目如下: Given a string S of lowercase letters, a duplicate removal consists of choosing two adjacent a ...
- http各个状态码的含义
http各个状态码的含义:由三位数字组成,第一位定义了状态码的类型 常见状态码及解决方法 404:找不到,地址错误 500:逻辑错误 400:一般是入参不匹配 504:超时 2开头:(请求成功)表示成 ...
- HashMap测试程序1
package com.iotek.map; import java.util.Collection;import java.util.HashMap;import java.util.Map;imp ...
- Hadoop ”No room for reduce task“问题处理
早上发现一个任务有20个reduce,但是只有四个正常完成,剩余16个等待了8个小时才分配执行(集群槽位资源充足) 解决方法:查看了集群的log,发现有这种warn: -- ::, WARN org. ...
- php面试专题---12、JavaScript和jQuery基础考点
php面试专题---12.JavaScript和jQuery基础考点 一.总结 一句话总结: 比较常考察的是JavaScript的HTML样式操作以及jQuery的选择器和事件.样式操作. 1.下列不 ...
- ACM2014-04训练计划
这是我写的第一篇博文,先简单说说今天的状态吧,毕竟我的第一篇博文是今天诞生的.这学期开学以来各种乱忙,开学初准备高数竞赛决赛,而后有一段时间疯狂学习英语,一直到前几天国创项目中的任务,准备数模竞赛,上 ...
- Java内置多线程框架Executor
JDK1.5之后,增加了一个Executor让我们能更好的使用多线程. 它位于java.util.concurrent包下 因为是JDK内置类库,我们不需要导入任何第三方jar包. 代码实例: imp ...