HDU4930 Fighting the Landlords

【ChatGPT实战案例】ChatGPT如何帮助产品经理高效工作? 1. 产品经理主要工作方向, 2. 具体工作中,向ChatGPT提问参考 阅读详情

Fighting the Landlords


Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 165 Accepted Submission(s): 55


Problem Description
Fighting the Landlords is a card game which has been a heat for years in China. The game goes with the 54 poker cards for 3 players, where the “Landlord” has 20 cards and the other two (the “Farmers”) have 17. The Landlord wins if he/she has no cards left, and the farmer team wins if either of the Farmer have no cards left. The game uses the concept of hands, and some fundamental rules are used to compare the cards. For convenience, here we only consider the following categories of cards:

1.Solo: a single card. The priority is: Y (i.e. colored Joker) > X (i.e. Black & White Joker) > 2 > A (Ace) > K (King) > Q (Queen) > J (Jack) > T (10) > 9 > 8 > 7 > 6 > 5 > 4 > 3. It’s the basic rank of cards.

2.Pair : two matching cards of equal rank (e.g. 3-3, 4-4, 2-2 etc.). Note that the two Jokers cannot form a Pair (it’s another category of cards). The comparison is based on the rank of Solo, where 2-2 is the highest, A-A comes second, and 3-3 is the lowest.

3.Trio: three cards of the same rank (e.g. 3-3-3, J-J-J etc.). The priority is similar to the two categories above: 2-2-2 > A-A-A > K-K-K > . . . > 3-3-3.

4.Trio-Solo: three cards of the same rank with a Solo as the kicker. Note that the Solo and the Trio should be different rank of cards (e.g. 3-3-3-A, 4-4-4-X etc.). Here, the Kicker’s rank is irrelevant to the comparison, and the Trio’s rank determines the priority. For example, 4-4-4-3 > 3-3-3-2.

5.Trio-Pair : three cards of the same rank with a Pair as the kicker (e.g. 3-3- 3-2-2, J-J-J-Q-Q etc.). The comparison is as the same as Trio-Solo, where the Trio is the only factor to be considered. For example,4-4-4-5-5 > 3-3-3-2-2. Note again, that two jokers cannot form a Pair.

6.Four-Dual: four cards of the same rank with two cards as the kicker. Here, it’s allowed for the two kickers to share the same rank. The four same cards dominates the comparison: 5-5-5-5-3-4 > 4-4-4-4-2-2.

In the categories above, a player can only beat the prior hand using of the same category but not the others. For example, only a prior Solo can beat a Solo while a Pair cannot. But there’re exceptions:

7.Nuke: X-Y (JOKER-joker). It can beat everything in the game.

8.Bomb: 4 cards of the same rank. It can beat any other category except Nuke or another Bomb with a higher rank. The rank of Bombs follows the rank of individual cards: 2-2-2-2 is the highest and 3-3-3-3 is the lowest.

Given the cards of both yours and the next player’s, please judge whether you have a way to play a hand of cards that the next player cannot beat you in this round. If you no longer have cards after playing, we consider that he cannot beat you either. You may see the sample for more details.


Input
The input contains several test cases. The number of test cases T (T<=20) occurs in the first line of input.

Each test case consists of two lines. Both of them contain a string indicating your cards and the next player’s, respectively. The length of each string doesn’t exceed 17, and each single card will occur at most 4 times totally on two players’ hands except that the two Jokers each occurs only once.


Output
For each test case, output Yes if you can reach your goal, otherwise output No.


Sample Input
4
33A
2
33A
22
33
22
5559T
9993


Sample Output
Yes
No
Yes
Yes


Source
2014 Multi-University Training Contest 6

题意就是斗地主了,不过这个只要你任意出一种牌,别人压不住你就算你赢。。。没有顺子而已。。

直接模拟。。。没有什么好说的。。给几组数据。。代码很渣

44438

333XY

结果:No

4455

777

结果:No

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char a[30];
char b[30];
int aj[9];
int bj[9];
struct NUM
{
    int id;
    int n;
};
NUM an[18];
NUM bn[18];
bool cmp1(char xx,char yy)
{
    return xx<yy;
}
bool cmp2(NUM xx,NUM yy)
{
    if(xx.n==yy.n)
        return xx.id<yy.id;
    return xx.n>yy.n;
}
void init(char s[],NUM num[],int judge[])
{
    int i;
    for(i=0;i<18;i++)
    {
        num[i].n=0;
        num[i].id=i;
    }
    int len=strlen(s);
    for(i=0;i<len;i++)
    {
        if(s[i]<='9'&&s[i]>='3')
        {
            num[s[i]-'0'].n++;
        }
        else if(s[i]=='T')
            num[10].n++;
        else if(s[i]=='J')
            num[11].n++;
        else if(s[i]=='Q')
            num[12].n++;
        else if(s[i]=='K')
            num[13].n++;
        else if(s[i]=='A')
            num[14].n++;
        else if(s[i]=='2')
            num[15].n++;
        else if(s[i]=='X')
        {
            num[16].n++;
            judge[7]=16;
        }
        else if(s[i]=='Y')
        {
            num[17].n++;
            judge[8]=17;
        }
    }
    sort(num,num+18,cmp2);
    judge[0]=0;
    for(i=0;i<18;i++)
    {
        if(num[i].n&&num[i].id>judge[0])
            judge[0]=num[i].id;
        if(num[i].n==4)
        {
            judge[4]=num[i].id;
        }
        else if(num[i].n==3)
        {
            judge[2]=num[i].id;
        }
        else if(num[i].n==2)
        {
            judge[1]=num[i].id;
        }
    }
    judge[2]=max(judge[4],judge[2]);
    judge[1]=max(judge[2],judge[1]);
    judge[5]=(judge[1]>0&&len>=5&&judge[2]!=judge[1])?judge[2]:0;
    judge[3]=(len>=4)?judge[2]:0;
    judge[6]=(len>=6)?judge[4]:0;
}
int find()
{
    int len=strlen(a);
    if(len==1)
        return 1;
    if(aj[7]&&aj[8])
        return 1;
    if(aj[1]&&len==2)
        return 1;
    if(aj[2]&&len==3)
        return 1;
    if(len==4)
    {
        if(aj[3]||aj[4])
            return 1;
    }
    if(len==5&&aj[5])
    {
        return 1;
    }
    if(len==6&&aj[6])
        return 1;
    return 0;
}
int ping()
{
    int i;
    for(i=0;i<=6;i++)
    {
        if(aj[i]&&aj[i]>=bj[i])
        {
            return 1;
        }
    }
    return 0;
}
int main()
{
    int T;
    int i;
    scanf("%d",&T);
    while(T--)
    {
        scanf(" %s",a);
        scanf(" %s",b);
        memset(aj,0,sizeof(aj));
        memset(bj,0,sizeof(bj));
        init(a,an,aj);
        init(b,bn,bj);
        if(find())
            printf("Yes\n");
        else
        {
            if(bj[7]&&bj[8])
                printf("No\n");
            else if(bj[4])
            {
                if(aj[4]>bj[4])
                    printf("Yes\n");
                else
                    printf("No\n");
            }
            else
            {
                if(ping())
                    printf("Yes\n");
                else
                    printf("No\n");
            }
        }
    }
    return 0;
}



蓝牙协议栈详解(3)——BTstack BTstack是一个轻量级蓝牙协议栈,支持经典蓝牙(BR/EDR)和低功耗蓝牙(BLE)。它采用事件驱动模型,可运行在MCU/CPU上,通过HCI接口与蓝牙控制器通信。协议栈包含完整的蓝牙协议层支持,如L2CAP、RFCOMM、ATT/GATT等,并提供丰富的示例代码。 主要特点包括模块化设计、开源授权、支持多种HCI传输方式(UART/USB)和操作系统适配。开发时需要关注事件驱动编程模型、内存配置优化、HCI传输稳定性等问题。典型应用场景包括SPP串口通信、BLE外设开发等。 使用建议从最小示例开始,逐 阅读详情

相关推荐

疾病负担研究(GBD)介绍

今天我们来聊一聊第一个公共数据库——GBD数据库,全称叫做global burden of disease(全球疾病负担),该数据库每年都会更新,目前已经更新到GBD2019。 这里直接给大家贴出网址:Global Burden of Disease Study 2019 (GBD 2019) Data Resources | GHDx 上图中红色圈圈标识的就是数据库的数据获取界面的链接,大家直接点击即可. 数据的检索十分方便: Context下拉菜单中可以选择不同的选项,默认是caus

weixin_44240228的博客 1万+

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

HDU 4930 Fighting the Landlords 题目链接 题意:就是题中那几种牌型,如果先手能一步走完,或者一步让后手无法管上,就赢 思路:先枚举出两个人所有可能的牌型的最大值,然后再去判断即可 代码: #include #include #include using namespace std; struct Player { int

Remilia's 943

Pinocchio 安装教程|机器人学的必备库

安装pinocchio,不要安装pip3 install pinocchio!

darcsdn 1660

HDU 4930 Fighting the Landlords (超级暴力+读懂题意)

斗地主!!不会玩这游戏,真得好好去学下,哈哈哈哈

n-1 1059

若依框架(ruoyi vue版)集成jeecg积木报表整体完整实用教程(超长篇幅耐心阅读)

若依框架(ruoyi vue版)集成jeecg积木报表整体完整实用教程,主要说明jeecg积木报表的集成、jeecg积木报表嵌入若依菜单、token权限控制,以及iframe嵌入表格等内容。

weixin_53067723的博客 4641

【S32K】S32K144入门笔记(4) Lin (Lin stack组件) 驱动超声波雷达实例

0. 引言 Lin这块是我一直没弄懂的部分。很多东西一知半解,当时感觉是硬凑了答案出来。 果然过标的时候出了问题,几个小伙伴帮忙一起刷夜也没搞定,好在标还是顺利过了,不然罪过大了。 之前做lin这块一直用的是linStack组件,这部分包含了协议栈部分,需要对lin的协议比较清楚和理解才好配置。 尤其是,图形界面配置完成后会生成一个ldf文件,这个文件很重要,所有的代码都是基于这个文件生成的,但是这个文件我确认没找到什么介绍资料,所以很多配置都是一点一点凑出来的,再实际验证的。 抓住这次写文档的机会,把当时

YoYo的桃子树 1万+

Fighting the Landlords HDU - 4930

Fighting the Landlords HDU - 4930题目描述 Fighting the Landlords is a card game which has been a heat for years in China. The game goes with the 54 poker cards for 3 players, where the “Landlord” has 20 c

退役的铜牌狗 453

Android Camera性能优化概述

做camera性能优化方面的工作有几年了,想写一篇文章简单介绍一下其中涉及到的具体技术,这篇文章会大概介绍一下涉及到的技术。

weixin_42136255的博客 4023

hdu 4930 Fighting the Landlords

模拟。 分别考虑出一张牌,一对,三张牌,三带一,三带二,

Jane的私房菜 626

【Arc GIS 零基础教学】土地利用类型图的绘制方法

​Hi,我是胡学长!今天教大家怎么利用Arc GIS 绘制土地利用类型图。土地利用类型图是表达土地资源的利用现状、地域差异和分类的专题地图。它是研究土地利用的重要工具和基础资料,同时也是土地利用调查研究的主要成果之一。在编制土地利用图的基础上,对当前利用的合理程度和存在的问题、进一步利用的潜力、合理利用的方向和途径,进行综合分析和评价。因此,土地利用图是调整土地利用结构,因地制宜进行农业、工矿业和交通布局、城镇建设、区域规划、国土整治、农业区划等的一项重要科学依据。......

一起来交流学习吧 1万+

uniapp(vue3)- 详解安装/使用pinia报错reportJSException >>>> exception function:createInstanceContext, excepti

uniapp vue3 pinia报错reportJSException >>>> exception function:createInstanceContext, exception:white screen cause create instanceContext failed,check js stack -> at useStore,H5网页,微信小程序,安卓App,苹果App,nvue,uniapp安装使用pinia出现报错at useStore,uniapp+vue3+ts 使用pinia报

🏆 前端领域优质创作者 4047

HDU4930 Fighting the Landlords(AC)

Fighting the Landlords  Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Description    Fighting the Landlords is a card game which has been a hea

twinslizzy的博客 2956

国科大学习资料--人工智能原理与算法-2020年期末考试题解析(学长整理)

国科大学习资料–人工智能原理与算法-2020年期末考试题解析 张文生老师主讲 试卷共有6道题,题目不难,希望大家能取得好的成绩。 3.9 传教士和野人问题。三个传教士和三个野人在河的一岸,有一条能载一个人或者两个人的船。请设法使所有人都渡到河的另一岸,要求在任何地方野人数都不能多于传教士的人数。这个问题在AI领域中很有名,是因为它是第一个从分析的观点探讨问题形式化的论文的主题(Amarel,1968)。 a. 请对该问题进行详细形式化,只描述确保该问题求解所必需的特性。画出完整的状态空间图。 b. 应用合适

无名何许人的博客 4786

HDU 4930 Fighting the Landlords 斗地主模拟

题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4930 题意:虽然题目很长,但是其实就是一直在介绍我们很熟悉的斗地主规则。要求这一轮里是否A出牌后B没有牌可以压过A。 解题思路:这道题尤其要注意出牌的先后性,先处理先手一方的情况,因为它是先出牌的一方。如果先手(A)有王炸的优先级是最高的,最先处理这种情况,直接输出Yes。然后处理先手可以一次性打

fawks96的专栏 512

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

hdu 4930 Fighting the Landlords(模拟)

题目连接:hdu 4930 Fighting the Landlords 题目大意:就是两个人玩斗地主,有8种牌型,单张,一对,三张,三带一,三带对,四带二,四炸,王炸。要求上家这一轮出牌下家管不上或者上家将牌走完则输出yes。 解题思路:总共就20张牌,枚举220种出牌方法,然后保留每种牌型的最大值,判断一下就可以了,注意细节。 #include #include #inclu

不慌不忙、不急不躁 1359

hdu 4930 Fighting the Landlords(模拟)

http://acm.hdu.edu.cn/showproblem.php?pid=4930 Fighting the LandlordsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 1337 Accepted Submis

492

Hdu 4930 Fighting the Landlords 简单模拟

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4930 题目大意:斗地主,两个人

e的专栏 564

HDU 4930 : Fighting the Landlords(模拟)

J - Fighting the Landlords Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4930 Description Fighting the Landlords is a car

Hytai的专栏 546

HDU4930-Fighting the Landlords

题意:斗地主,就是要自己出牌,使得对手在这一轮无法出牌,或者有出牌的可能,但是你的牌已经走完了。如果符合这些条件的话,输出Yes,否则输出No。 思路:先预处理能直接把牌走完的情况,如果不行的话就直接暴力枚举能获胜的情况。 #include #include #include #include using namespace std; const int MAXN

懒人一枚。 897

HDU 4930 Fighting the Landlords 模拟

_(:зゝ∠)_ 4带2居然不是炸弹,, #include #include #include #include #include #include #include #include using namespace std; #define N 18 #define inf 1000000 #define ll int struct node{ int a[N];

九野的博客 1282

hdu4930 Fighting the Landlords(模拟 多校6)

hdu4930 Fighting the Landlords(模拟 多校6)

1558

HDU4930:Fighting the Landlords(模拟)

Problem Description Fighting the Landlords is a card game which has been a heat for years in China. The game goes with the 54 poker cards for 3 players, where the “Landlord” has 20 cards and the ot

ACM!荣耀之路! 1744

hdu 4930 Fighting the Landlords (模拟)

Fighting the Landlords Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 160    Accepted Submission(s): 52 Problem Description Figh

Coding A World 1171
上一篇: HDU4915 Parenthese sequence
下一篇: HDU4923 Room and Moor
eeeaaaaa
博客等级 码龄12年 2粉丝 155原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值