CodeForces
来源:互联网 发布:java通过构造方法传参 编辑:程序博客网 时间:2024/06/16 13:29
/* 这题的策略其实比较容易想到,因为每个人说单词的时候,都会尽量使得对方无词可说,所以只要当时还有两人都会的单词没被说过,那么大家在说单词时,一定会优先选择这样的单词 所以,我们可以先统计一下两个人都会的单词,姑且记作 same 将 PolandBall 会的单词记作 n, EnemyBall 会的记作 m 然后分类讨论以下两种情况: 如果 same 是偶数,那就显得比较公平了,因为这时,PolandBall 取胜只需 n - same > m - same 就完全是“只有 PolandBall 会的单词”,和“只有 EnemyBall 会的单词”进行比较即可 如果 same 是奇数,其实对 PolandBall 更有利,因为根据规则,我们知道 PolandBall 先说单词,所以这剩下的最后一个单词,必定是 PolandBall 说的,而此时,EnemyBall 需要拿出一个 “只有 EnemyBall 会的单词”与其抗衡,也即,PolandBall 取胜,只需 n - same > m - same - 1 分析到这里,就可以直接写代码了*/
#include <iostream>#include <string>#define rep(i, k, n) for (int i = k; i < (n); i++)const int N = 1e3 + 10;using namespace std;int n, m;string a[N], b[N];int main(){cin >> n >> m;rep(i, 0, n)cin >> a[i];rep(i, 0, m)cin >> b[i];int same = 0;rep(i, 0, n)rep(j, 0, m)if ( a[i] == b[j] ){same++;}if ( same % 2 && n > m - 1 ) cout << "YES" << endl;else if ( !(same % 2) && n > m ) cout << "YES" << endl;else cout << "NO" << endl;return 0;}
阅读全文
0 0
- codeforces~~~
- Codeforces
- codeforces
- Codeforces
- codeforces
- codeforces
- Codeforces
- Codeforces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- css基础-盒子(div)模型、属性、边框线的设置、padding、margin、网站的设置思想(float),图片代替列表符号
- 为何优秀的程序员会不断离去
- 网易2017春招编程题:魔力手环 [python]
- 【解决】ERROR in xxx.js from UglifyJs
- 技术与技术人员的价值
- CodeForces
- 删除公众号菜单-php开发公众号视频教程
- fnl+wrf 报错记录
- Linux-001-Linux发展历史和发行版本
- 把数组排成最小的数
- redis事务
- Java 加载资源文件整理
- Linux-002-Linux应用领域与开源软件介绍
- Codeforces Round #430 (Div. 2) E. Nikita and game