题意:斗地主,就是要自己出牌。使得对手在这一轮无法出牌,或者有出牌的可能。可是你的牌已经走完了。假设符合这些条件的话,输出Yes。否则输出No。

思路:先预处理能直接把牌走完的情况,假设不行的话就直接暴力枚举能获胜的情况。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std; const int MAXN = 20; char s1[MAXN], s2[MAXN];
int p1[MAXN], p2[MAXN], num1[MAXN], num2[MAXN]; void change(char ch, int *p) {
if (ch == 'Y') p[17] = 1;
else if (ch == 'X') p[16] = 1;
else if (ch == '2') p[15]++;
else if (ch == 'A') p[14]++;
else if (ch == 'K') p[13]++;
else if (ch == 'Q') p[12]++;
else if (ch == 'J') p[11]++;
else if (ch == 'T') p[10]++;
else p[ch - '0']++;
} void count(int n, int *num) {
if (n == 1) num[1]++;
else if (n == 2) num[2]++;
else if (n == 3) num[3]++;
else if (n == 4) num[4]++;
} int slove(int n) {
if (n == 1) return 1;
else if (n == 2 && num1[2]) return 1;
else if (n == 2 && p1[16] && p1[18]) return 1;
else if (n == 3 && num1[3]) return 1;
else if (n == 4 && (num1[4] || (num1[3] && num1[1]))) return 1;
else if (n == 5 && num1[3] && num1[2]) return 1;
else if (n == 6 && num1[4]) return 1;
return 0;
} int main() {
int cas;
scanf("%d", &cas);
while (cas--) {
scanf("%s%s", s1, s2);
int l1 = strlen(s1);
int l2 = strlen(s2);
memset(p1, 0, sizeof(p1));
memset(p2, 0, sizeof(p2));
for (int i = 0; i < l1; i++)
change(s1[i], p1);
for (int i = 0; i < l2; i++)
change(s2[i], p2);
memset(num1, 0, sizeof(num1));
memset(num2, 0, sizeof(num2));
for (int i = 0; i < 18; i++)
count(p1[i], num1);
for (int i = 0; i < 18; i++)
count(p2[i], num2); int flag = 0;
if (l1 <= 6) //推断是否能直接把牌走完的情况
flag = slove(l1); if (flag) {
printf("Yes\n");
continue;
} if (p1[16] && p1[17]) { //推断两方是否存在一方有王炸的情况
printf("Yes\n");
continue;
}
if (p2[16] && p2[17]) {
printf("No\n");
continue;
} if (num1[4]) { //推断炸的存在的情况
int a = 1, b = 1;
for (int i = 18; i >= 3; i--)
if (p1[i] == 4) {
a = i;
break;
}
for (int i = 18; i >= 3; i--)
if (p2[i] == 4) {
b = i;
break;
}
if (a > b)
flag = 1;
if (b > a)
flag = -1;
}
if (flag == 1) {
printf("Yes\n");
continue;
}
if (flag == -1) {
printf("No\n");
continue;
} int c = 0; //推断之存在对手有炸的情况
for (int i = 18; i >= 3; i--)
if (p2[i] == 4) {
c = 1;
break;
}
if (c) {
printf("No\n");
continue;
} if (num1[3]) { //推断有三带是否能直接获胜的情况
int a = 1, b = 1;
for (int i = 18; i >= 3; i--)
if (p1[i] == 3) {
a = i;
break;
}
for (int i = 18; i >= 3; i--)
if (p2[i] == 3) {
b = i;
break;
}
if (num1[2] && !num2[2]) {
flag = 1;
}
if (a > b)
flag = 1;
}
if (num1[2]) { //推断出对子是否能直接获胜的情况
int a = 1, b = 1;
for (int i = 18; i >= 3; i--)
if (p1[i] == 2 || p1[i] == 3) {
a = i;
break;
}
for (int i = 18; i >= 3; i--)
if (p2[i] == 2 || p2[i] == 3) {
b = i;
break;
}
if (a >= b)
flag = 1;
}
if (num1[1]) { //推断出单是否能直接获胜的情况
int a = 1, b = 1;
for (int i = 18; i >= 3; i--)
if (p1[i]) {
a = i;
break;
}
for (int i = 18; i >= 3; i--)
if (p2[i]) {
b = i;
break;
}
if (a >= b)
flag = 1;
} if (flag)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}

HDU4930-Fighting the Landlords的更多相关文章

  1. HDU4930 Fighting the Landlords 模拟

    Fighting the Landlords Fighting the Landlords Time Limit: 2000/1000 MS (Java/Others)    Memory Limit ...

  2. hdu4930 Fighting the Landlords(模拟 多校6)

    题目链接:pid=4930">http://acm.hdu.edu.cn/showproblem.php? pid=4930 Fighting the Landlords Time L ...

  3. HDU-4930 Fighting the Landlords 多校训练赛斗地主

    仅仅须要推断一个回合就能够了,枚举推断能够一次出全然部牌或者大过对面的牌的可能,注意的是4张同样的牌带两张牌的话是能够被炸弹炸的. #include <iostream> #include ...

  4. HDU 4930 Fighting the Landlords(扯淡模拟题)

    Fighting the Landlords 大意: 斗地主... . 分别给出两把手牌,肯定都合法.每张牌大小顺序是Y (i.e. colored Joker) > X (i.e. Black ...

  5. HDU 4930 Fighting the Landlords(暴力枚举+模拟)

    HDU 4930 Fighting the Landlords 题目链接 题意:就是题中那几种牌型.假设先手能一步走完.或者一步让后手无法管上,就赢 思路:先枚举出两个人全部可能的牌型的最大值.然后再 ...

  6. HDU 4930 Fighting the Landlords(模拟)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4930 解题报告:斗地主,加了一个四张可以带两张不一样的牌,也可以带一对,判断打出一手牌之后,如果对手没 ...

  7. HDU 4930 Fighting the Landlords --多Trick,较复杂模拟

    题意:两个人A和B在打牌,只有题目给出的几种牌能出若A第一次出牌B压不住或者A一次就把牌出完了,那么A赢,输出Yes,否则若A牌没出完而且被B压住了,那么A输,输出No. 解法:知道规则,看清题目,搞 ...

  8. 2014多校第六场 1010 || HDU 4930 Fighting the Landlords (模拟)

    题目链接 题意 : 玩斗地主,出一把,只要你这一把对方要不了或者你出这一把之后手里没牌了就算你赢. 思路 : 一开始看了第一段以为要出很多次,实际上只问了第一次你能不能赢或者能不能把牌出尽. #inc ...

  9. 2014 多校联合训练赛6 Fighting the Landlords

    本场比赛的三个水题之一,题意是两个玩家每人都持有一手牌,问第一个玩家是否有一种出牌方法使得在第一回和对方无牌可出.直接模拟即可,注意一次出完的情况,一开始没主意,wa了一发. #include< ...

  10. hdu 4930 Fighting the Landlords--2014 Multi-University Training Contest 6

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4930 Fighting the Landlords Time Limit: 2000/1000 MS ...

随机推荐

  1. 08C#事件

    C#事件 1.2      事件 事件是C#语言内置的语法,可以定义和处理事件,为使用组件编程提供了良好的基础. 1.16.1       事件驱动 Windows操作系统把用户的动作都看作消息,C# ...

  2. 06C#类

    C#类 1.2      类的继承 在1.3节,定义了一个描述个人情况的类Person,如果我们需要定义一个雇员类,当然可以从头开始定义雇员类Employee.但这样不能利用Person类中已定义的函 ...

  3. WebService 服务开发

    开发 WebService 服务首先需要根据接口的要求编写相关的 wsdl 文件.编写 wsdl 文件需要先对 XML 语法.XML Schema 语法以及 SOAP 语法有一些简单了解. 假设需要提 ...

  4. python 导入beautifulsoup报错

    导入Beautifulsoup 报错 AttributeError: 'module' object has no attribute '_base' 解决方法:   pip install --up ...

  5. 关于js事件冒泡和事件捕获

    事件捕获指的是从document到触发事件的那个节点,即自上而下的去触发事件.相反的,事件冒泡是自下而上的去触发事件.绑定事件方法的第三个参数,就是控制事件触发顺序是否为事件捕获.true,事件捕获: ...

  6. [JOYOI] 1051 选课

    题目限制 时间限制 内存限制 评测方式 题目来源 1000ms 131072KiB 标准比较器 Local 题目描述 学校实行学分制.每门的必修课都有固定的学分,同时还必须获得相应的选修课程学分.学校 ...

  7. Linux终端以及bash

    目 录 第1章 Linux系统终端概述    1 1.1 图形化    1 1.2 字符终端    1 1.3 who和w    1 1.3.1 who    1 1.3.2 w    1 1.3.3 ...

  8. Python之微信-微信机器人

    一 简介 二 登录微信 三 微信好友男女比例 四 微信好友地域分布 五 微信聊天机器人 一 简介 wxpy基于itchat,使用了 Web 微信的通讯协议,,通过大量接口优化提升了模块的易用性,并进行 ...

  9. flash-热风焊盘的制作

    计算部分: 热风焊盘的内径(ID)等于钻孔直径+20mil, 外径(OD)等于Anti-pad的直径,通常是比焊盘的直径大20mil. 开口宽度等于(OD-ID)/2+10mil,保留整数位. 如果焊 ...

  10. PHP学习笔记<参数的传递>

    简单的例子说明参数在PHP文件之间的传递(有两个PHP文件在index.php文件上点击链接,在跳转的时候,依据参数的不同在neirong.php文件中显示不同的内容) inde.php的内容如下: ...