2019CCPC湖南全国邀请赛(广东省赛、江苏省赛)重现赛 K.SSY and JLBD

博客介绍了神秘国家简单的麻将规则,玩家有14张牌,有“十三幺”和“九莲宝灯”两种获胜方式。给出玩家14张牌的输入格式,要求判断能以哪种方式获胜,若都不满足则输出未知,思路是进行模拟。

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

#include<cstdio>
#include<cstring>
using namespace std;
char str[14][14];
int main(){
    int i;
    while(scanf("%s",str[0])!=EOF){
        for(i=1;i<14;i++){
            scanf("%s",str[i]);
        }
        int flag1=1,flag2=1;
        int s=0,p=0,w=0;
        for(i=0;i<14;i++){
            if(str[i][1]=='s') s++;
            else if(str[i][1]=='p') p++;
            else if(str[i][1]=='w') w++;
        }
        if(s==14||p==14||w==14){
                //puts("done");
            int a[20]={0};
            for(i=0;i<14;i++){
                a[str[i][0]-'0']++;
            }
        //for(i=1;i<=9;i++) printf("%d\n",a[i]);
            if(a[1]>=3&&a[9]>=3){
                for(i=2;i<=8;i++){
                    if(a[i]==0) {flag2=0;break;}
                }
            }
            else {
                flag2=0;
            }
            if (flag2==1) {printf("jiulianbaodeng!\n");continue;}
        }
        else {
            int b[6][6]={0};
            int c[10]={0};
            int cnt=0;
            for(i=0;i<14;i++){
                if(strcmp(str[i],"dong")==0) c[1]++;
                else if(strcmp(str[i],"xi")==0) c[2]++;
                else if(strcmp(str[i],"nan")==0) c[3]++;
                else if(strcmp(str[i],"bei")==0) c[4]++;
                else if(strcmp(str[i],"zhong")==0) c[5]++;
                else if(strcmp(str[i],"fa")==0) c[6]++;
                else if(strcmp(str[i],"bai")==0) c[7]++;
                else if(str[i][0]=='1'&&str[i][1]=='s') b[1][1]++;
                else if(str[i][0]=='1'&&str[i][1]=='p') b[1][2]++;
                else if(str[i][0]=='1'&&str[i][1]=='w') b[1][3]++;
                else if(str[i][0]=='9'&&str[i][1]=='s') b[2][1]++;
                else if(str[i][0]=='9'&&str[i][1]=='p') b[2][2]++;
                else if(str[i][0]=='9'&&str[i][1]=='w') b[2][3]++;
            }
            for(i=1;i<=7;i++){
                cnt+=c[i];
            }
            for(i=1;i<=3;i++){
                cnt+=b[1][i]+b[2][i];
            }
            if(cnt<=13) flag1=0;
            for(i=1;i<=7;i++){
                if(c[i]==0){flag1=0;break;}
            }
            for(i=1;i<=3;i++){
                if(b[1][i]==0||b[2][i]==0){
                    flag1=0;break;
                }
            }
            if(flag1==1){
                printf("shisanyao!\n");
                continue;
            }
        }
        printf("I dont know!\n");
    }
    return 0;
}

Problem Description

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!

思路:模拟就好了

#include<cstdio>
#include<cstring>
using namespace std;
char str[14][14];
int main(){
    int i;
    while(scanf("%s",str[0])!=EOF){
        for(i=1;i<14;i++){
            scanf("%s",str[i]);
        }
        int flag1=1,flag2=1;
        int s=0,p=0,w=0;
        for(i=0;i<14;i++){
            if(str[i][1]=='s') s++;
            else if(str[i][1]=='p') p++;
            else if(str[i][1]=='w') w++;
        }
        if(s==14||p==14||w==14){
                //puts("done");
            int a[20]={0};
            for(i=0;i<14;i++){
                a[str[i][0]-'0']++;
            }
        //for(i=1;i<=9;i++) printf("%d\n",a[i]);
            if(a[1]>=3&&a[9]>=3){
                for(i=2;i<=8;i++){
                    if(a[i]==0) {flag2=0;break;}
                }
            }
            else {
                flag2=0;
            }
            if (flag2==1) {printf("jiulianbaodeng!\n");continue;}
        }
        else {
            int b[6][6]={0};
            int c[10]={0};
            int cnt=0;
            for(i=0;i<14;i++){
                if(strcmp(str[i],"dong")==0) c[1]++;
                else if(strcmp(str[i],"xi")==0) c[2]++;
                else if(strcmp(str[i],"nan")==0) c[3]++;
                else if(strcmp(str[i],"bei")==0) c[4]++;
                else if(strcmp(str[i],"zhong")==0) c[5]++;
                else if(strcmp(str[i],"fa")==0) c[6]++;
                else if(strcmp(str[i],"bai")==0) c[7]++;
                else if(str[i][0]=='1'&&str[i][1]=='s') b[1][1]++;
                else if(str[i][0]=='1'&&str[i][1]=='p') b[1][2]++;
                else if(str[i][0]=='1'&&str[i][1]=='w') b[1][3]++;
                else if(str[i][0]=='9'&&str[i][1]=='s') b[2][1]++;
                else if(str[i][0]=='9'&&str[i][1]=='p') b[2][2]++;
                else if(str[i][0]=='9'&&str[i][1]=='w') b[2][3]++;
            }
            for(i=1;i<=7;i++){
                cnt+=c[i];
            }
            for(i=1;i<=3;i++){
                cnt+=b[1][i]+b[2][i];
            }
            if(cnt<=13) flag1=0;
            for(i=1;i<=7;i++){
                if(c[i]==0){flag1=0;break;}
            }
            for(i=1;i<=3;i++){
                if(b[1][i]==0||b[2][i]==0){
                    flag1=0;break;
                }
            }
            if(flag1==1){
                printf("shisanyao!\n");
                continue;
            }
        }
        printf("I dont know!\n");
    }
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值