SSY and JLBD (简单模拟)

本文介绍了一个神秘国度的麻将规则,玩家需要拥有特定的牌型才能获胜。一是'十三幺',需要所有的一和九以及全部七种字牌;二是'九莲宝灯',要求同一种花色的牌且一和九至少三张,二到八至少一张。给定玩家的14张牌,你需要判断他们可以使用哪种方式赢得游戏。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Mahjong is a board game with a long history. But Mahjong has different rules in different city. 

A deck of mahjong consists of 136 cards. It contains 1-9 card in three suits,and Seven kinds of word card("dong","nan","xi","bei",“zhong”,"fa","bai"),there are 4 same cards for each kind of card in a deck of mahjong . 

In a mysterious country, the rules of mahjong are very simple.In the game,each Player has 14 cards.There are only two ways people can win the game: 



1. shisanyao:You should have all 1 and 9 card in three suits and seven kinds of word card at the same time,and an extra card with any kind of 1 and 9 or word. 

2. jiulianbaodeng:Firstly,You should make sure that you have the same suit in your hand.Secondly, for card "1" and card "9",you should have at least three . but for card "2" to card "8",at least one.For example, both "11112345678999" and "11122345678999" can win the game. 



Now you know a player's 14 cards. Please judge which card type he can use to win the game. 

Input

The input file contains 14 lines.Each line has a string representing a card. 

For three suits of card "1" to card "9",We use two characters for the type,the first character a is number 1 to 9,and the second character b represents the suit.(a∈{1,2,3,4,5,6,7,8,9},b∈{s,p,w}a∈{1,2,3,4,5,6,7,8,9},b∈{s,p,w}) 

For the word cards,as shown in the description,we use full spelling pinyin represent them. 

Output

If player ‘s card meet the “shisanyao” condition, you should output "shisanyao!". 

If player ‘s card meet the “jiulianbaodeng” condition, you should output "jiulianbaodeng!". 

Otherwise,you should output "I dont know!".

Sample Input

1w
5w
2w
6w
5w
9w
9w
7w
1w
3w
9w
4w
1w
8w

Sample Output

jiulianbaodeng!

两种胡法

1.shisanyao:三套1和9 + 七种花牌 + 一张额外牌(只能是1和9和花牌)

2.jiulianbaodeng:(同花色)至少三张1和三张9 + 至少一张2和一张8

 

#include<bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long ll;

int main()
{
    map<string, int> ma;
    map<char, int> shu;
    map<char, int> c;
    string str;
    int ans = 0;
    for(int i=0;i<14;i++)
    {
        cin >> str;
        if(str[0] >='0' && str[0] <= '9')
        {
            shu[str[0]]++;//geshu
            if(ma[str] == 0)
            {
               c[str[0]]++;//paixing
            }
        }
        else
        {
            if(ma[str] == 0)
            {
                ans++;
            }
        }
        ma[str]++;
    }
    if((ans == 7 && c['1'] >=3 && c['9'] >=3) &&(shu['1'] > 3 || shu['9'] > 3) )
    {
       cout << "shisanyao!" << endl;
    }
    else if(ans == 0 && c['1'] == 1 && c['9'] == 1 && c['2'] == 1 && c['8'] == 1 && shu['1'] >=3 && shu['9'] >= 3 && shu['2'] >=1 && shu['8'] >=1)
    {
       cout << "jiulianbaodeng!" << endl;
    }
    else cout << "I dont know!" << endl;
    return 0;
}

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值