HDU 6542  SSY and JLBD

 HDU 6542  SSY and JLBD

 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})

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!


 

```cpp
#include<bits/stdc++.h>
/*dong
nan
xi
bei
zhong
fa
bai
1w
9w
1s
9s
1p
9p
9p
*/
using namespace  std;
int main()
{
    char a[14][10];
    char word[7][10]={"dong","nan","xi","bei","zhong","fa","bai"};
    int s[10]={0},p[10]={0},w[10]={0},word1[10]={0};
    for(int i=0;i<14;i++)//计数 
    {
        gets(a[i]);
        
        if(a[i][0]<='9'&&a[i][0]>='0')
        {
            if(a[i][1]=='w')
                w[a[i][0]-'0']++;
            if(a[i][1]=='s')
                s[a[i][0]-'0']++;
            if(a[i][1]=='p')
                p[a[i][0]-'0']++;
        }
        else
        {
            for(int j=0;j<7;j++)
            {
                if(strcmp(a[i],word[j])==0)
                {
                    word1[j+1]++;
                }    
            }
        }
    }
    int flag = 1; 
    for(int i=1;i<=9;i++)//判断是否为同一个suit 
    {
        if(i>=2&&i<=8)
        {
            if(s[i]>=1)
                flag=0;
            if(w[i]>=1)
                flag=0;
            if(p[i]>=1)
                flag=0;
        }
        s[0]+=s[i];
        w[0]+=w[i];
        p[0]+=p[i];
        word1[0]+=word1[i];
    }
    for(int i=1;i<=7;i++)//判断word是否成立 
        if(word1[i]==0)
            flag=0;
    if(s[0]==14&&s[1]>=3&&s[9]>=3||    w[0]==14&&w[1]>=3&&w[9]>=3||    p[0]==14&&p[1]>=3&&p[9]>=3)
    {
        cout<<"jiulianbaodeng!"<<endl;
    }
    else if(s[1]>=1&&s[9]>=1&&
    w[1]>=1&&w[9]>=1&&p[1]>=1
    &&p[9]>=1&&flag==1)
    {
        cout<<"shisanyao!" <<endl;
    }
    else
        cout<<"I dont know!"<<endl;
}
```

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值