CodeForces 755B PolandBall and Game
来源:互联网 发布:丫头蟋蟀罐淘宝店铺 编辑:程序博客网 时间:2024/05/17 03:58
题目链接:http://codeforces.com/contest/755/problem/B
题意:两个人玩游戏,每人轮流说一个词,不能说之前说过的,然后谁先不能说谁就输,问你最后谁赢了,每个人说的词是已经准备好了的第一个人有n个词,第二个人有m个词,第一个人先手,如果第一个人赢了就输出YES,否则输出NO
解析:首先想相同的词,肯定每个人是一人说一个,然后减去那些相同的词,假设有cnt个词不同,如果cnt是偶数,一人轮流锁一个刚好说完,但是如果是奇数的话,第一个人能比第二个人多说一个,所以n也就少减一个,然后判断n和m谁大,n>m输出YES,否则NO
#include <bits/stdc++.h>using namespace std;const int maxn = 3e5+100;const int inf = 0x7fffffff;set<string >ans;int main(void){ string a; int n,m; scanf("%d %d",&n,&m); int cnt = 0; for(int i=0;i<n;i++) { cin>>a; ans.insert(a); } for(int i=0;i<m;i++) { cin>>a; if(ans.find(a)!=ans.end()) cnt++; } n -= cnt/2,m -= (cnt+1)/2; if(n>m) puts("YES"); else puts("NO"); return 0;}
0 0
- 【codeforces 755B】PolandBall and Game
- codeforces-755-B PolandBall and Game
- Codeforces 755-B. PolandBall and Game(贪心)
- 【Codeforces 755 B PolandBall and Game】
- Codeforces 755B-PolandBall and Game
- CodeForces 755B PolandBall and Game
- 755B PolandBall and Game
- 文章标题 Coderforces 755B : PolandBall and Game(水)
- 【codeforces 755A】PolandBall and Hypothesis
- 【codeforces 755C】PolandBall and Forest
- 【codeforces 755D】PolandBall and Polygon
- Codeforces 755C-PolandBall and Forest
- Codeforces 755D-PolandBall and Polygon
- CodeForces 755C PolandBall and Forest
- codeforces755B. PolandBall and Game(map)
- codeforces 755E PolandBall and White-Red graph
- codeforces 755 d PolandBall and Polygon(找规律)
- codeforces-755D-PolandBall and Polygon(数学题)
- CS231n-3-Loss Function & Optimization
- LAMP平台的构成组件
- C++组合模式
- ssd论文阅读记录
- Fire!(bfs) UVA
- CodeForces 755B PolandBall and Game
- 素数链表——初级素数表+链表基本操作
- 快速排序Quicksort(附快速排序程序)
- 20170505Windows02_WindowsDataType
- 【Android】ContentProvider详解(一)
- 生成KD树并用KD树求最近邻点
- spring mvc 使用junit 测试 controller
- HTDP学习笔记(1)--DrRacket的安装和配置
- Android 通知栏Notification的整合 全面学习 (一个DEMO让你完全了解它)