Zoj 3671 japan ese Mahjong III

Source: Internet
Author: User

Question link: http://acm.zju.edu.cn/onlinejudge/showProblem.do? Problemcode = 3671.


Japan ese Mahjong III Time Limit: 2 seconds memory limit: 65536 KB

MahjongIs a game of skill, strategy and calculation and involves a certain degree of chance. In this problem, we concentrate onJapanese Mahjong, A variation of mahjong. For brief, all of the wordMahjongMentioned following referJapanese Mahjong.

Japanese Mahjong is usually played with 136 tiles, which can be organized into several categories:

  • Suited tiles. All suited tiles are of a rank and a suit. there are three suits of tiles, with ranks ranging from one to nine. there are four tiles of each rank and suit combination, thus there are 36 tiles in a suit, and 108 suited tiles in total.
    • TheCircleSuit
    • TheBambooSuit
    • TheCharacterSuit
  • Honor tiles. Honor tiles are tiles that do not have a rank or suit. they are divided into two categories. there are four types of Wind tiles and three types of Dragon tiles, with four of each type of honor tile. thus, there are 16 Wind tiles and 12 Dragon tiles for 28 honor tiles.
    • WindTiles. The Wind tiles consist of four kinds of tile:East,South,West, AndNorth.
    • DragonTiles. The dragon titles consist of three types of tile:Red,Green,White.

In this problem, we introduce two abnormal kindsWinning handDifferent from the normalWinning hand, Which consist of four melds and one eyes.

  1. Seven pairs: The hand consists of seven different pairs. No two pairs are the same. For example:
  2. Thirteen Orphans: The hand consists of thirteen kinds of tiles:Circle one, circle nine, bamboo one, bamboo nine, character one, character nine, east, south, west, north, red, greenAndWhite.Only one kind of them are two tiles, while the others are all only one tile. For example:

Now, givenHandWith 14 tiles, can you answer this hand is which kind of abnormal kindWinning hand?

Input

There are multiple cases. Each case consists of 28 characters in one line, describing 14 tiles. The manner for describing each type of tile is:

  • Two characters stand for one tile.
  • ForSuited tiles, The first is a integer ranged from one to nine, the tile's rank, and the second is a character:'P'ForCircleSuit,'S'ForBambooSuit, and'M'ForCharacterSuit.
  • ForHonor tiles, The first is a integer: from one to seven standsEast,South,West,North,White,Green, AndRedRespectively. The second one is always'Z'.
We promise that the input is a legal hand, which means there isn' t another type of tiles described above or there are more than four same tiles.

Output

For each case, if the hand isSeven pairs, Output "seven pairs". If the hand isThirteen Orphans, Output "Thirteen Orphans". If the hand is neitherSeven pairsNorThirteen Orphans, Output "neither! ".

Sample Input
1z1z2z2z3z3z4z4z5z5z6z6z7z7z1s9s1m9m1p9p1z2z3z4z5z6z7z7z1s9s1m9m1p9p1z2z3z4z5z6z7z7p
Sample output
Seven PairsThirteen OrphansNeither!
Author: Yu, Xiaoyao
Contest: zoj monthly, November 2012
Submit status


A simple simulated question. We can use a two-dimensional array a [I] [J] to record the status. A [0] [J] indicates jp a [1] [J] indicates JS, a [2] [J] indicates JM, and a [3] [J] indicates JZ.


#include<iostream>#include<cstring>#include<cstdio>#include<vector>#include<string>#include<sstream>#include<algorithm>#include<cmath>#include<vector>#include<set>#include<cstdlib>#include<map>using namespace std;#define CLR(A) memset(A,0,sizeof(A))const int MAX=50;int a[10][10];char str[MAX];int main(){    while(~scanf("%s",str)){        CLR(a);int len=strlen(str);        for(int i=0;i<len-1;i++){            if(str[i+1]=='p') a[0][str[i]-'0']++;            if(str[i+1]=='s') a[1][str[i]-'0']++;            if(str[i+1]=='m') a[2][str[i]-'0']++;            if(str[i+1]=='z') a[3][str[i]-'0']++;        }        bool flag=0;        for(int i=0;i<4;i++){            for(int j=1;j<10;j++){                if(a[i][j]&&a[i][j]!=2){                    flag=1;break;                }            }            if(flag) break;        }        if(!flag) cout<<"Seven Pairs"<<endl;        else{            if(a[0][1]&&a[0][9]&&a[1][1]&&a[1][9]&&a[2][1]&&a[2][9]&&a[3][1]&&a[3][2]&&a[3][3]&&a[3][4]&&a[3][5]&&a[3][6]&&a[3][7]){                if(a[0][1]==2||a[0][9]==2||a[1][1]==2||a[1][9]==2||a[2][1]==2||a[2][9]==2||a[3][1]==2||a[3][2]==2||a[3][3]==2||a[3][4]==2||a[3][5]==2||a[3][6]==2||a[3][7]==2){                    cout<<"Thirteen Orphans"<<endl;                }                else cout<<"Neither!"<<endl;            }            else cout<<"Neither!"<<endl;        }    }    return 0;}


Zoj 3671 japan ese Mahjong III

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.