hdu4431 枚举+模拟

本文深入探讨了游戏开发领域的多种技术,包括游戏引擎、图像处理、AR特效以及AI音视频处理等关键领域。从Unity、Unreal Engine到Cocos2dX,覆盖了游戏开发的基础和进阶技术。同时,文章还详细介绍了AI在音视频处理的应用,如视频分割、语义识别、语音变声和终端AI边缘计算等前沿技术。

Mahjong

Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3889 Accepted Submission(s): 778


Problem Description
Japanese Mahjong is a four-player game. The game needs four people to sit around a desk and play with a set of Mahjong tiles. A set of Mahjong tiles contains four copies of the tiles described next:

One to nine Man, which we use 1m to 9m to represent;

One to nine Sou, which we use 1s to 9s to represent;

One to nine Pin, which we use 1p to 9p to represent;

Character tiles, which are:Ton, Nan, Sei, Pei, Haku, Hatsu, Chun, which we use 1c to 7c to represent.

A winning state means a set of 14 tiles that normally contains a pair of same tiles (which we call "eyes") and four melds. A meld is formed by either three same tiles(1m, 1m, 1m or 2c, 2c, 2c for example) or three continuous non-character tiles(1m, 2m, 3m or 5s, 6s, 7s for example).

However, there are two special winning states that are different with the description above, which are:
"Chii Toitsu", which means 7 different pairs of tiles;
"Kokushi Muso", which means a set of tiles that contains all these tiles: 1m, 9m, 1p, 9p, 1s, 9s and all 7 character tiles. And the rest tile should also be one of the 13 tiles above.

And the game starts with four players receiving 13 tiles. In each round every player must draw one tile from the deck one by one. If he reaches a winning state with these 14 tiles, he can say "Tsu Mo" and win the game. Otherwise he should discard one of his 14 tiles. And if the tile he throws out can form a winning state with the 13 tiles of any other player, the player can say "Ron" and win the game.

Now the question is, given the 13 tiles you have, does there exist any tiles that can form a winning state with your tiles?

(Notes: Some of the pictures and descriptions above come from Wikipedia.)

Input
The input data begins with a integer T(1≤T≤20000). Next are T cases, each of which contains 13 tiles. The description of every tile is as above.

Output
For each cases, if there actually exists some tiles that can form a winning state with the 13 tiles given, print the number first and then print all those tiles in order as the description order of tiles above. Otherwise print a line "Nooten"(without quotation marks).

Sample Input
  
  
2 1s 2s 3s 2c 2c 2c 2p 3p 5m 6m 7m 1p 1p 1p 1p 2p 3p 4s 5s 6s 7c 7c 3s 3s 2m 2m

Sample Output
  
  
2 1p 4p Nooten

Source

#include<stdio.h>
#include<string.h>
#define N 40
int mark[N],b[N],vis[N];
int judge1(int x)
{
    int num=0,i;
    for(i=1;i<=34;i++)
    {//必须是7对不相同的牌
        if(mark[i]==2)
            num++;
    }
    if(num==7)
      return 1;
    else
       return 0;
}
int judge2(int x)
{//处理13妖的胡法
    int j,i;
    if(mark[1]==0||mark[9]==0||mark[10]==0||mark[18]==0||mark[19]==0||mark[27]==0)
        return 0;//必须出现的数字
    for(j=28;j<=34;j++)
    {//必须出现的文字
        if(mark[j]==0)
            return 0;
    }
    for(i=1;i<=27;i++)
    {//不能出现的数字
        if(i!=1&&i!=9&&i!=10&&i!=18&&i!=19&&i!=27)
        {
            if(mark[i]!=0)
                return 0;
        }
    }
    return 1;
}
int f(int k)
{//处理是否越出当前牌的范围
    if(k==9||k==18||k==27)
        return 0;
    if(k+1==9||k+1==18||k+1==27)
        return 0;
    return 1;
}
int judge3(int x)
{
    int i,j,k,num,flag=0;
    for(i=1;i<=34;i++)
    {
        if(mark[i]>=2)
        {//取任意两张相同的牌,当对子。
            num=0;
            for(j=1;j<=34;j++)
                vis[j]=mark[j];
          vis[i]-=2;
          for(j=1;j<=27;j++)
          {//判断是数字的有没有三张相同的和顺子的
              if(vis[j]>=3)
              {//大于等于三张的先取出3张
                  num++;
                  vis[j]-=3;
              }
              while(f(j)&&vis[j]&&vis[j+1]&&vis[j+2])
              {
                  num++;
                  vis[j]--; vis[j+1]--; vis[j+2]--;
              }
          }//判断文字的
          for(j=28;j<=34;j++)
          {
              if(vis[j]>=3)
                 num++;
          }
          if(num==4)
          {
              flag=1;
              break;
          }
        }
    }
    if(flag==1)
        return 1;
    else
        return 0;
}
int main()
{
    int t,i,a,k;
    char str[10];
    scanf("%d",&t);
    while(t--)
    {
        memset(mark,0,sizeof(mark));
        for(i=1;i<=13;i++)
        {//把牌转换成数字的形式
            scanf("%s",str);
            a=str[0]-'0';
            if(str[1]=='s')
               a+=9;
            else if(str[1]=='p')
                a+=18;
            else  if(str[1]=='c')
                a+=27;
            mark[a]++;
        }
       k=0;
       for(i=1;i<=34;i++)
       {
           mark[i]++;//注意判断mark[i]<=4
          if(mark[i]<=4&&(judge1(i)||judge2(i)||judge3(i)))
            b[k++]=i;
          mark[i]--;
       }
       if(k==0)
       {
           printf("Nooten\n");
           continue;
       }
       printf("%d",k);
       for(i=0;i<k;i++)
       {
           //printf("%d\n",b[i]);
           if(b[i]%9==0)
             printf(" 9");
           else
            printf(" %d",b[i]%9);
           if(b[i]<=9)
            printf("m");
           else if(b[i]<=18)
            printf("s");
           else if(b[i]<=27)
             printf("p");
           else
            printf("c");
       }
       printf("\n");
    }
    return 0;
}
/*
111
1s 1s 2s 2s 4s 4s 5s 5s 6s 6s 7s 7s 8s
1s 9s 1m 9m 1p 9p 1c 2c 3c 4c 5c 6c 7c
1s 9s 1m 9m 1p 9p 1c 2c 3c 4c 5c 6c 1m
2s 3s 4s 5s 6s 7s 7s 1c 1c 1c 2c 2c 2c
2s 3s 4s 5s 6s 7s 7s 7s 1c 1c 2c 2c 2c
1s 1s 2s 2s 3s 4s 4s 5s 5s 6s 6s 1c 1c
1s 1s 1s 2s 3s 4s 5s 6s 7s 8s 9s 9s 9s
1s 1s 1s 1s 2s 3s 9s 9s 9s 2s 3s 1c 1c
1s 1s 1s 1s 2s 2s 2s 3s 3s 3s 4s 4s 4s
2s 2s 2s 3s 4s 4s 5s 5s 5s 6s 6s 7s 9s
2s 2s 2s 3s 4s 4s 5s 5s 5s 6s 6s 7s 8s
1p 1p 1p 1p 2p 2p 3p 3p 4p 4p 5p 5p 8s
2p 2p 2p 3p 3p 4p 4p 4p 5p 5p 5p 6p 6p
1c 2c 3c 4c 5c 6c 7c 1s 9s 1m 9m 1p 9p
*/


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值