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 + ...
随机推荐
- windows 安装 mysql 5.6
从官方网站下载安装包:mysql-5.6.33-winx64.zip,解压到d:\java,然后将解压后的bin目录加入系统环境变量Path中,进入mysql根目录,编辑my-default.ini, ...
- rocketmq架构设计
# 架构设计 1 技术架构 RocketMQ架构上主要分为四部分,如上图所示: Producer:消息发布的角色,支持分布式集群方式部署.Producer通过MQ的负载均衡模块选择相应的Broker集 ...
- URLEncode解决url中有特殊字符的问题
问题:图片上传后的url地址中有&等特殊字符,页面传到后端时被自动处理成了& 解决:前端对url进行URLEncode,后端收到后进行URLDecode 总结:需要在请求u ...
- Linux启动redis提示 /var/run/redis_6379.pid exists, process is already running or crashed
执行启动命令:service redisd start 提示信息:/var/run/redis_6379.pid exists, process is already running or crash ...
- CSU 1551 Longest Increasing Subsequence Again(树状数组 或者 LIS变形)
题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1551 升级版:Uva 1471 题意: 让你求删除一段连续的子序列之后的LIS. 题 ...
- Remote desktop manager共享账号
因为多个远程机器,是会用了域账号进行登录的.而域账号的密码,三个月之后,密码强制过期 添加一个新的entry,类型是Credential Entry,然后选择用户名/密码 在remote deskto ...
- leetcode 88. C++ 合并两个有序数组
Leetcode 88. 合并两个有序数组 给定两个有序整数数组 nums1 和 nums2,将 nums2 合并到 nums1 中,使得 num1 成为一个有序数组. 说明: 初始化 nums1 和 ...
- jQuery中的serializer序列化—炒鸡好用
jQuery.serializer()序列化 serialize()函数用于序列化一组表单元素,将表单内容编码为用于提交的字符串. serialize()函数常用于将表单内容序列化,以便用于AJAX提 ...
- Elasticsearch+Logstash+Kibana搭建日志平台
1 ELK简介 ELK是Elasticsearch+Logstash+Kibana的简称 ElasticSearch是一个基于Lucene的分布式全文搜索引擎,提供 RESTful API进行数据读写 ...
- iintellij IDEA运行环境使用教程
1.官网:https://www.jetbrains.com 链接: https://pan.baidu.com/s/10QKLn1bGEW9W0pXEp6WR1A 提取码: vt2b 看官觉得有用留 ...